Parallel SSH and sudo
Posted on Mon 26 August 2013 in Linux
Please keep in mind this post is from 2013 and may no longer be valid.
So for some reason you have multiple machines to manage but don't have SSH-keys on them. It's still possible to use parallel-ssh and sudo without having to enter any passwords. Create a file with your password in it (suggest you remove the file as soon as you are done). Then install parallel-ssh and sshpass :
apt-get install sshpass pssh
Use the programs like this:
sshpass -f ~/tmppass parallel-ssh -I -A -h hostsfile "sudo -S yum upgrade -y" < ~/tmppass
tmppass is your password file. For parallel-ssh, -I reads from input and -A asks for password. And for sudo, -S reads the password from stdin.
You might also want to disable StrictHostKeyChecking:
sshpass -f ~/tmppass parallel-ssh -x "StrictHostKeyChecking=no" -I -A -h hostsfile "sudo -S yum upgrade -y" < ~/tmppass