SSH Port Forwarding VNC under Mac OS X

If you’ve ever needed to remotely administer Mac OS X remotely, VNC combined with port forwarding can be very handy. A command like the following below, will forward localport 5901 to 5900 on the remote machive via a ssh tunnel.

ssh -L 5901:localhost:5900 bugga.net

Under recent versions of OS X however this does not work. The reason is because OS X is fully IPv6 aware and has some special quirks preventing this from working fully. The solution, use the loopback address rather than localhost and your SSH tunnel should function as expected.
ssh -L 5901:127.0.0.1:5900 bugga.net