M BUZZ CRAZE NEWS
// general

Using parallel-ssh with public key

By David Jones

I have configured the remote ssh server for login via public-private key pair (only). I can login into the server and run commands using ssh:

ssh -i ~/.ssh/my_key echo fu

I'd like to send commands to the server using parallel-ssh from pssh package. I use -H option to specify list of servers (one server), -i to print results on screen and -A so that program would ask for a password to the key. The documentation states that it is capable of passing arguments down to ssh using -x or -X. However, neither the following command work:

parallel-ssh -A -i -H "" -X "-i ~/.ssh/my_key" 'echo fu'

output being:

Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:
[1] 17:03:35 [FAILURE] Exited with error code 255
Stderr: Warning: Identity file ~/.ssh/my_key not accessible: No such file or directory.
Permission denied (publickey).

(I can see the file with ll ~/.ssh/my_key. )

Nor this command succeeds:

 parallel-ssh -A -i -H "" -x '-i ~/.ssh/my_key' 'echo fu'

output:

Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:
[1] 17:15:06 [FAILURE] administrator@192.168.0.118 Exited with error code 255
Stderr: Enter passphrase for key '/home/local_user/.ssh/my_key':
Permission denied (publickey).

This second one is completely weird since man parallel-ssh claims that -A option does "Prompt for a password and pass it to ssh. The password may be used for either to unlock a key or for password authentication."

So, how would one use a password-protected public key inside parallel-ssh command?

2

1 Answer

This is a bug in the pssh program which is just a collection of a python scripts. These scripts resort to parsing the ssh program output to interface with it.

One way to get it working is to fix it yourself.dpkg -L pssh will list all the files installed with the pssh package.askpass_client.py is the file that needs modification. Line 67 is

if not prompt.strip().lower().endswith('password:'):

and should be:

if not ( prompt.strip().lower().endswith('password:') or 'enter passphrase for key' in prompt.strip().lower()):

Then the command

parallel-ssh -A -i -H "" -x "-i ~/.ssh/my_key" 'echo fu'

will work.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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