I am tunneling an nc connection to my target host (example.com) over an ssh connection to my gateway. Below is my .ssh/config setup for this connection:
Host target
Hostname example.com
HostKeyAlias target
ProxyCommand ssh me@gateway /bin/nc example.com 22
This is great and allows me to ssh to the target host in one step. What I would like to do is be able to tunnel an NX or VNC session over this connection.
Anyone know how this might be done?
Here's how a VNC session can be created over an ssh tunnel with a gateway hop in between the client and target machines:
/etc/ssh/sshd_config (on target machine) must have these lines:
Your path to xauth may be different, but by default sshd looks in the wrong location so this value should be set.
.ssh/config (on the client machine):
Then from the client I can run
This starts an X session on my client as well as an ssh connection to example.com. Now, just a couple more commands on the remote host to bring up VNC:In the above commands, :n is is the display number where you want to start vnc and the display where vncviewer should look for the vnc session. Since this looks like a local connection to VNC it is a good idea to specify some better encodings as vncviewer will default to raw, giving poor performance over the network.
That's it!
I think you should use port forwarding that SSH already can do:
This will forward port 5900 from your local machine to example.com through gateway. Now just "vncviewer localhost" from your local machine.