Use SSH to access servers behind firewalls

Sep 09, '02 09:52:29AM

Contributed by: AlwaysMac

I often want to access my office's intranet and Samba fileserver while at home. There's a firewall in the way of course. However SSH from my static DSL IP is allowed, so the solution is to forward local ports on the Mac to a box with sshd inside the firewall.

For example if you want to access an internal intranet, connect to an internal proxy from your office desktop via an ssh connection:

  % ssh -N -L 8888:proxy.xyz.com:3128 \
my.office.desktop.xyz.com
What is going on here is connections to your Mac's localhost port 8888 are tunneled to your office machine, which then forwards it to the office web proxy that is listening on port 3128. Then set your browser's proxy to localhost port 8888 and start browsing!

To access a Samba file server use something like this:
  % sudo ssh -v -l username -i ~username/.ssh/identity -N -L \
139:samba.xyz.com:139 my.office.desktop.xyz.com
The go to Finder -> Go -> Connect to Server -> Address, and input the folder you want, ie smb://localhost/Docs.

These examples assume your intranet servers are in the public DNS; if not, you'll have to add entries to your Mac's hosts file.

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2002090906522942