3

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 ssh -oProxyCommand="sshpass -p ssh -W %h:%p user@jumphost" user@server "ls"

jlengrand
  • 12,152
  • 14
  • 57
  • 87

1 Answers1

3

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.

Roland van Laar
  • 162
  • 1
  • 1
  • 8
  • That did the trick! With the verbose flag I realized that I had to use sshpass twice. I added the solution in the question. Thanks! – jlengrand May 09 '18 at 11:29