Tunneling Samba over SSH on Mac OS X

When using localhost for tunneling Samba on Mac OS X, the following error message will be displayed on trying to connect to smb://localhost:

The server “127.0.0.1” is available on your computer. Access the volumes and files locally.

A simple workaround is to add an alias to lo0:

sudo ifconfig lo0 alias 127.0.0.2 up

Then simply create the tunnel:

sudo ssh -L 127.0.0.2:139:DESTINATIONIP:139 SSHUSER@SSHSERVER

Now it’s possible to connect to smb://127.0.0.2 without a problem.