execute command via ssh with password

by lapots   Last Updated February 11, 2019 09:00 AM

I want to execute two command on two servers via ssh from my local machine

ssh [email protected]"$APP_HOST" "sh /home/agents/startAgent.sh --auto-shutdown > agent.log 2>&1 </dev/null & "
ssh [email protected]"$DB_HOST" "sh /home/agents/startAgent.sh --auto-shutdown > agent.log 2>&1 </dev/null & "

with APP_HOST it works fine and starts .sh. script on remote just ok.

But my DB_HOST asks for password when I try to run the same command. For now I don't have configured access without password (no rights to do).

But how to provide password inside the command itself without input?

Tags : linux

Answers 2

If you have a different behaviour for the same ssh command, it's probably an SSH miscounfiguration.

Check you SSH config file, it there is no difference, check you ssh keys.

What does a simple ssh [email protected]"$DB_HOST" do?

February 11, 2019 08:40 AM

You have to install private key of user launch remotely the command to the user in the remote server. If you have the password of remote user you have the right to install your private key, just run

ssh-copy-if [email protected]"$DB_HOST"

You will prompt for the user password and from that moment on you can login to remote server without password prompt. No configuration have to be change openssh server is configured to accept key authentication for default.

February 11, 2019 08:47 AM

Related Questions

Updated January 09, 2018 20:00 PM

Updated December 21, 2016 08:00 AM

Updated April 25, 2017 09:00 AM

Updated May 14, 2017 10:00 AM

Updated July 19, 2017 17:00 PM