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:
X11Forwarding yes
XAuthLocation /usr/bin/xauth
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):
Host example.com
Hostname foo.example.com
HostKeyAlias example.com
ProxyCommand ssh -t -C [email protected] /bin/nc %h 22
Then from the client I can run
me@localhost$ ssh -X -C example.com
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:
[email protected]$ vncserver :n
[email protected]$ vncviewer -encodings "copyrect tight zlib corre rre raw" :n
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!