SSH passthrough?
The chain to do is host2 -> host1 -> localhost:5555
.
The -J
option allows easily to do this from host2 using the -J
/ ProxyJump
feature:
-J
destinationConnect to the target host by first making a
ssh
connection to the jump host described by destination and then establishing a TCP forwarding to the ultimate destination from there.[...]
So without yet considering the option for port 5555:
ssh -J host1 localhost
Also as documented right after...
Note that configuration directives supplied on the command-line generally apply to the destination host and not any specified jump hosts. Use
~/.ssh/config
to specify configuration for jump hosts.
...extra options like specifying a port don't affect the Jump Host but will only affect the final target. Just add back the port option:
ssh -p 5555 -J host1 localhost
You could even have different users on all 3 systems and specify the user names in the command:
ssh -p 5555 -J myhost1user@host1 myvmuser@localhost
Note: Each ssh server requires its own separate authentication. If you don't use features to avoid having to provide passwords like by using ssh keys, you will probably be asked twice in a row a password: once for connecting to host1, once for connecting to the VM behind localhost:5555.