If your first SSH server (
my.server.com) supports TCP Port Forwarding, you can forward a port on your local system (
ssh -fNL 2022:my.server2.com:22 myUser@my.server.com
This will forward port 2022 on
localhost to port 22 on
my.server2.com. Then you can connect directly to the second server:
In Nautilus, you can connect using
-fN flags send SSH to the background, and creates a problem in closing it. There are three ways out:
ssh -fNL 2022:my.server2.com:22 myUser@my.server.com sleep 10
Now connect using Nautilus before the sleep command finishes executing (10 seconds). The connection will be kept alive as long as Nautilus is connected. When done, disconnect from Nautilus and the connection will be stopped.
Let the command wait for input
ssh -tL 2022:my.server2.com:22 myUser@my.server.com 'read -p"Press Enter to exit: "'
read command will wait for input. Press Enter when you're done to close the connection.
Look up the connection process and kill it
pgrep -fa fNL
This will show you all processes which have
fNL in the command line (there should only be your SSH connection process).
kill the PID of the right process if there are more than one, or use
pkill if there is only one process:
pkill -f fNL
This is pretty much the only option for connections that have already been established using
Run no command, and exit as usual
ssh -L 2022:my.server2.com:22 myUser@my.server.com
This will open a normal shell, from which you can exit as you normally do.