Reputation: 12807
In our environments, we have several servers in production. Every time I want to search for something, it may be in 1 of 4 different servers. I am creating a script to automate this search, so that I directly know which server is involved.
I am connecting through a jumphost.
So far the following command works fine :
$ ssh -oProxyCommand="ssh -W %h:%p user@jumphost" user@server "ls"
Now, because I have to run this several times, I am searching for a way to only have to use the password once.
Both the jumphost and the server require the same password, and public keys are not an option (not allowed, I literally cannot do it).
I have been reading about sshpass for this and am trying this :
$ sshpass -p password ssh -oProxyCommand="ssh -W %h:%p user@jumphost" user@server "ls"
(I know -p is not safe and will use -e of -f as soon as I am successful with this step).
When I do this, I can login in both systems but the command returns before I see the result of ls. I have tried to have the -t option to ssh without any success.
I have also tried the -J option from ssh, with the same results (command returns without returning any results).
$ sshpass -p password ssh -J user@jumphost user@server "ls"
Any suggestions?
EDIT:
Solution was to use sshpass twice :
$ sshpass -p password_server ssh -oProxyCommand="sshpass -p password_jumphost ssh -W %h:%p user@jumphost" user@server "ls"
Upvotes: 4
Views: 4763
Reputation: 172
Try running ssh in verbose mode:
ssh -vvv -oProxyCommand="ssh -W %h:%p user@jumphost" user@server "ls"
I'm sure it will show something of interest. A hook with which you can figure this out.
Upvotes: 4