SSH Key Script – How to Pass Your Password to Your SSH Key via a Script

bashscriptingsshssh-agentssh-keys

I am writing a script that will allow me to retrieve a file from all of my servers at once. I have SSH keys in place in order to log into my servers. My SSH key however requires a password.

The script I am writing will not be automated, it will only ever be run manually. So my script prompts the user for the SSH key password.

How can I send the password to the SSH key as it connects to each server. I am trying to avoid having to type my password in for each server.

I know I could use 'expect', but am hoping there is a simple way to do this. Maybe some environment variable?

Thanks.

Best Answer

Why not use ssh-agent for this?
See the man page for additional details. :)