In general, you need something like this:
vncviewer -via 192.0.2.1 192.168.1.1
(which works with e.g. tigervnc in Linux). It builds an SSH tunnel automatically.
But you can build this tunnel by hand. First of all, you build a tunnel:
ssh -L 5901:192.168.1.1:5900 192.0.2.1
This will work with Windows's SSH Client feature installed (which is OpenSSH). If you use Putty, you can add this tunnel via session configuration GUI. This will make SSH client to listen on localhost:5901
.
Second, you connect with vncviewer
to the display localhost:1
, to this SSH socket, and if the target destination is working correctly it will tunnel you to the target server's VNC. The target will see you as connecting from 192.0.2.1's local IP (it might be 192.168.1.2 or something like this).
A slight explanation about numbers: in VNC terminology the number after colon means "display number" and not "TCP port number". It gets added to 5900, so display #1 is on the port 5901. If you want to specify port number directly, you use double colon ::
. I know, this is confusing, also some VNC clients don't use this scheme or relax these rules (e.g. if port 11801 doesn't answer they try 5901).