Jane Maths Jane Maths - 4 months ago 42
Bash Question

Running AWS jobs with GNU parallel - how to include private key?

How can one run parallel jobs on Amazon AWS EC2 with gnu parallel. I need to include private key to log in namely something like this does not work:

sh script.sh | parallel --sshlogin a@b.com -i "key.pem"


There are at least 3 ways to do it from GNU Parallel:

seq 10 | parallel --sshlogin 'ssh -i "key.pem" a@b.com' echo 

seq 10 | PARALLLEL_SSH='ssh -i "key.pem"' parallel --sshlogin a@b.com echo 

seq 10 | parallel --ssh 'ssh -i "key.pem"' --sshlogin a@b.com echo 

On top of that you can probably use .ssh/config (man ssh_config), so you use the same key for access to *.amazon.com.

Also you should learn ssh-agent. With that you can add multiple keys. Though this is only useful in sessions with a controlling terminal (e.g. not useful for cron jobs).