Linux: ubuntu 14.04.3 LTS

cat /tmp/passfile

sshpass -f /tmp/passfile parallel-ssh -I -A -h hostlist.txt "sudo -S ls -l /root" < /tmp/passfile

and the method described here in google discussion groups.google outputs the error as:

[1] 01:07:25 [FAILURE] Exited with error code 255
[2] 01:07:25 [FAILURE] Exited with error code 255

in the remote server I'm trying to connect its /var/log/auth.log has below message

Sep 24 19:20:52 ubu1401 sshd[5765]: Accepted password for ubuntu from port 55019 ssh2
Sep 24 19:20:52 ubu1401 sshd[5765]: pam_unix(sshd:session): session opened for user ubuntu by (uid=0)
Sep 24 19:21:26 ubu1401 sshd[5765]: pam_unix(sshd:session): session closed for user ubuntu
Sep 24 19:21:26 ubu1401 sudo: pam_unix(sudo:auth): conversation failed
Sep 24 19:21:26 ubu1401 sudo: pam_unix(sudo:auth): auth could not identify password for [ubuntu]
Sep 24 19:22:25 ubu1401 sshd[5791]: Connection closed by [preauth]
  • try adding -i -v to parallel-ssh to see if it provides any further clues. – meuh Sep 25 '16 at 19:43

To provide the password as securely, as possible, try this version (pssh on CentOS, Fedora and parallel-ssh on Ubuntu, Debian):

stty -echo; printf "Password: "; read PASS; stty echo; echo "${PASS}" | \ ssh <USER>@localhost "sudo -S dmesg"

and then adapt it to pssh like this:

stty -echo; printf "Password: "; read PASS; stty echo; echo "${PASS}" | \ pssh -H <USER>@localhost -o /tmp/output -I "sudo -S dmesg"

I use the same for ad-hoc collection of dumps from multiple servers. Stop it using Ctrl + C as usual. It will show [FAILURE] <HOST> Interrupted, but that is just because tcpdump would otherwise run infinitely - the output is still in the usual location. The -t 0 option is so the connection doesn't time out. I could also use tmux or screen and collect the dumps later.

stty -echo; printf "Password: "; read PASS; stty echo; echo "${PASS}" | \ pssh -h <HOSTFILE> -o /tmp/output -t 0 -I "sudo -S tcpdump -l -nn -vv -i any not port 22"

Make sure to include the correct ssh user and that you connected to those servers before. Testing things locally usually prevents taking down the entire fleet of servers. You can use the 127.0.0.X addresses instead of localhost to approximate multiple hosts.

  • 1
    For our Ubuntu 18.04 network, I had to add -x '-tt'; otherwise this was perfect. – Greg Glockner Jun 6 at 19:20
  • What does -tt do? I haven't seen this in the manual page (man parallel-ssh on Debian, Ubuntu). The -x option provides SSH connection arguments. A single "string" of arguments to SSH can also be provided with -X. – AdamKalisz Jun 10 at 21:31
  • 1
    -x '-tt' instructs pssh to send the -tt parameter to ssh, where it forces a pseudo-terminal allocation. This was necessary to get ssh to receive the password. – Greg Glockner Jun 10 at 23:08
  • Ok, now I see :-) – AdamKalisz Jun 11 at 10:22

have you tried running this via echoing the password in the shell?

echo "echo 'yourpassword'; sudo -S -c 'ls -l /root'"|pssh -I -H hostlist.txt

  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – countermode Oct 21 '16 at 14:58
  • @countermode this is how I run pssh sudo. That basically answers the question in the headline: "How to run sudo with parallel ssh" – Alex Oct 21 '16 at 16:26
  • i used ansible instead of the parallel ssh (i wanted to check disk usage ,free memory etc) – satch_boogie Oct 22 '16 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.