Ssh – Bash Script for SCP — SSH Keys

bashpassphrasescpsshterminal

I'm working as a programmer at the moment, and as a result need to constantly upload my software to remote systems for testing. I have about 7 machines which need to receive copies of everything.

At the moment, I have a short bash script with a scp performing the transfer for each remote machine:

echo -e "\nUpdating Taiwan Machine"
scp {file1,file} bschlinker@taiwan:/home/bschlinker/
echo -e "\nUpdating Wisconsin Machine"
scp -P 2400 {file1,file2} bschlinker@wisconsin:/home/bschlinker/

I'm painfully prompted for the password to each machine. I recognize I can solve this with SSH keys — but I don't want to have passwordless authentication to the remote machines via the key. As a result, I have a passphrase set on my SSH key. I read that after entering your passphrase once, it will remain active for the rest of the current terminal session. Is that true? If not, any ideas?

Best Answer

If you have a SSH agent running (such as the cleverly-named ssh-agent) then you can add the key to the agent and the SSH client will communicate with the agent to get the key from it.