I'm trying to run a remote command using SSH in a script. Host1 is connecting to Host2 to run a command.
I've setup the public keys between the two hosts so I don't need to use a password to make the ssh connection.
However, the key for Host1 was generated using a passphrase so SSH is still prompting for that passphrase when I try to SSH.
Is there any way to specify this passphrase so that my script can execute the command?
I know I can re-generate the key and choose not to use a passphrase; but I'm wondering if it is at all possible to use a passphrase and run ssh from a script?
I tried setting the SSH_ASKPASS environment variable as described here but that did not work. I'm assuming it only uses that variable for the password and not for the passphrase?
ssh-agentand thenssh-addyour key, you'll have to give the passphrase once, but the subsequentsshcommands will not require interaction. – glenn jackman Sep 18 '15 at 18:19ssh-agentis probably best, or set up a separate key the script has permission to use but the user doesn't. Won't stop a root user, though. – mykel Sep 20 '15 at 12:58