I'm using pdsh, but can't find any documentation or examples of specify the ssh key. Usually, I do ssh -i ~/.ssh/mykey.pem <address>. How do I change the pdsh command pdsh -R ssh -w ^server.txt "date" so I can specify my ssh key?


The manpage suggests an environment variable:

PDSH_SSH_ARGS_APPEND="-i $HOME/.ssh/mykey.pem"

You need to either export the variable (to make it available to pdsh's child processes) or define the variable and run the command in one go:

# Either:
export PDSH_SSH_ARGS_APPEND="-i $HOME/.ssh/mykey.pem"
pdsh -w^server.txt date

# Or
PDSH_SSH_ARGS_APPEND="-i $HOME/.ssh/mykey.pem" pdsh -w^server.txt date

I don't know why you gave -R ssh; for me it perfectly works without.

See also "pdsh can't find identity file, but ssh can. why?" on stackoverflow. The poster has a different problem (quoting) but uses the same approach.

  • Just tried and it didnt work :/ – Soubriquet Sep 14 '18 at 14:13
  • @Soubriquet Updated. Please try again. – PerlDuck Sep 14 '18 at 14:34
  • I keep on getting Permission denied (publickey). I'm using a list of hosts names formatted with one host on each line e.g. However, I also tried with ubuntu@ Neither worked. – Soubriquet Sep 14 '18 at 14:35
  • Permission denied (publickey). is a different error. It means you didn't distribute the corresponding public key to the remote hosts. Did you? – PerlDuck Sep 14 '18 at 14:39
  • Nvm works. I forgot to add thr PDSH_SSH_ARGS_APPEND to my .bashrc – Soubriquet Sep 14 '18 at 14:39

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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