Category Archives: Stupid SSH Tricks

SSH: The ultimate firewall poker

I’m in a hotel tonight and my internet connection is slow.  My friend sent me some cool YouTube videos that I wanted to check out and I was wondering if the hotel was limiting the bandwidth of YouTube?  A few days ago a friend of mine and I were talking about how to bypass corporate firewalls where companies block facebook/gmail/twitter access.  The way to check the YouTube problem and to bypass corporate firewalls can be done using the same solution:  SSH.

SSH encrypts data in and out of networks.  It is the ultimate firwall poker.  If you have SSH capabilities on at least one server on the internet and you can get to it then you can let any traffic in and out of a network.  Traffic is all encrypted so no sniffers know anything other than the fact that you have a connection from your machine (inside the corporate firewall / hotel wireless) on port 22 to some remote server that you have access to outside of the network you are on.

So here’s a quick test to see if YouTube was being throttled on this network, provided you have a Mac.  I’m doing this on OSX Lion.

1.  SSH to some remote internet server.  I have one, so I open a port to it:

ssh -D 2011 vallard@myserver.com

This essentially turns your ssh connection into a SOCKS server.

2.  Open chrome and navigate to:

chrome://settings/advanced

From here select ‘Change Proxy Settings’ and your Mac settings will come up.  Change the Socks settings as shown below:

That’s it.  Now you can visit http://whatismyip.com and see that the IP address changed.  You can also go to google maps and it will think you are in the city where the server is getting its network access from.

So, what about the YouTube video?  Seemed to be a bit better actually… but was hard to tell.   Probably was the same…

The other cool thing about this is how if you were in an airport then you can skip annoying adds that come on your web browser then this is how you could do it.

I’ve written in the past about all the cool tunnels you could make with SSH.   (See Trick 5 and Trick 6)

The point is:  There are ways around corporate policies that block you from checking sites you like, and ways to stop service providers from limiting your bandwidth based on the sites you visit.  Now obviously, you have to trust that the machine you SSH into allows you access to all that.  But that server is your choice!

opening VNC from behind a firewall

Here is the cast of characters:
1. blopr: A server that is behind a company firewall that I want to view its vnc session
2. netnet: A server that is on the internet that I have access to.
3. Me: The humble system admin who wants to view the VNC session on blopr.

Here is how I do it:

on Blopr:

vncserver :99 -depth 24 # and whatever other arguments you want to have.
ssh -R 5999:localhost:5999 root@netnet.example.com

On NetNet:

redir --lport=5989 --cport=5999 --caddr=127.0.0.1

On yours-truleys humble macbook pro:

vncviewer netnet.example.com:89  # enter the password for blopr's vnc session

Presto! You are in there my friend!

Bonus for you to try:  Suppose only SSH is allowed out from blopr?  This is left as an exercise to the reader.  But the trick is its very similar.