Search code examples
pythonpython-2.7pssh

pass the password as an argument in pssh


I am trying to write a script which will run commands on multiple machines with pssh. Is there any way to pass the password also in the same command line like below:

$ pssh -h pssh-host.txt -l root -A "pswd" echo "hi"
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:

Tried following solution:

sshpass -pabc pssh -h pssh-host.txt -l root -A echo "hi"
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
[1] 13:55:56 [SUCCESS] x
[2] 13:55:56 [SUCCESS] y

I do not want this Password: prompt. Can someone suggest a way for this?


Solution

  • Crossposting an answer by user568109 on Unix SE as Community Wiki:


    Found the solution on net not long after posting the question.

    The solution is:

    1. Install and use sshpass
    2. Use interactive mode to force the password which is just an empty string
    3. Used command cat local | sshpass -ppassword parallel-ssh -I -h new_hosts -l root -A 'cat >> remote'

    Original solution at: http://www.getreu.net/public/downloads/doc/Secure_Computer_Cluster_Administration_with_SSH/