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 & "
APP_HOST it works fine and starts
.sh. script on remote just ok.
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?
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?
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.