Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morteza-mori/ee19a3b524e01b5cb518346322ea8bbf to your computer and use it in GitHub Desktop.
Save morteza-mori/ee19a3b524e01b5cb518346322ea8bbf to your computer and use it in GitHub Desktop.
Proxy Jump in SSH Connections

Create config file for ssh (my.conf):

Host Server1
    User root
    HostName 192.168.100.10
Host Server2
    User root
    HostName 192.168.100.5
HostName Server3
    User root
    HostName 192.168.100.2
    ProxyJump Server1, Server2

Expect code (server3.sh):

#!/bin/sh
/usr/bin/expect <<EOF
spawn ssh -F my.conf Server3
expect "password"
send "PASSWORD-OF-SERVER-1\r"
expect "password"
send "PASSWORD-OF-SERVER-2\r"
expect "password"
send "PASSWORD-OF-SERVER-3\r"
expect "$"
interact
EOF

Try it:

$ server3.sh
@morteza-mori
Copy link
Author

You have old OpenSSH version that does not support the ProxyJump option. It was introduced in OpenSSH 7.3 so if you need to use it, you need to get this or newer version (it might not be provided by your distribution).

But as already said, you can rewrite every ProxyJump command using ProxyCommand (as pointed out in the original question).

https://superuser.com/a/1218139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment