I have several clients who have intranet applications running on servers that live behind a firewall. General there are firewall rules in place that allow me to access these servers via SSH (over port 22). But I need a way of using a web browser to test applications I’m developing on these servers.
Here’s a brief explanation of two ways I can do this, using Mac OS X on my end, and Linux on the remote end.
First, and easiest, is to use Apple’s new X11 server beta to use a browser running on the remote machine. To do this, I simply start up an X11 terminal client, use SSH to connect to the remote server, and then run Mozilla. To do this requires that X11 Forwarding be enabled on both the client and the server. On the OS X end, you need to uncomment the line ForwardX11 yes in the file /etc/ssh_config. On the remote end, make sure that the line X11Forwarding yes is uncommented in the file that’s probably located at sshd_config. Running Mozilla over a remote connection isn’t as fast or responsive as running a local browser, but it’s much snappier than I expected.
The second method is to use SSH port-forwarding and a local browser. Let’s say your remote host, behind the firewall, is called remotehost.com, it’s running a server on port 80, and your account on the remote machine is called myaccount. To port-foward on your OS X machine, simply call up a Terminal session and enter ssh -l myaccount -L 8080:remotehost.com:80 remotehost.com. Now you can call up a local browser, and browser to address localhost:8080. and you’ll be surfing the remote website.