SSH Tunnel in 30 Seconds (Mac OSX & Linux)

Some days, I wonder why VPN’s are really necessary when we can just use an SSH tunnel.
If you’re on Mac or a flavour of Linux, this SSH tunnelling tutorial is for you.

“A secure shell (SSH) tunnel consists of an encrypted tunnel created through a SSHprotocol connection. Users may set up SSH tunnels to transfer unencrypted traffic over a network through an encrypted channel.” – Wikipedia

Launch an SSH tunnel

To initiate your SSH tunnel, simply open Mac OSX / Linux Terminal and connect to your remote server via SSH with the following flags:

ssh -D 8080 -C -N username@example.com

This will launch our SSH tunnel on port 8080 and route all traffic (securely) through the server at example.com.

Browse the Web with Your SSH Tunnel (Chrome)

Now, let’s start browsing the web using our new SSH tunnel.

Mac OSX:

  1. Open Google Chrome
  2. Select ‘Chrome’ up the top left
  3. Select ‘Preferences’
  4. Select ‘Show advanced settings…’
  5. Select ‘Change proxy settings…’
  6. Select ‘SOCKS Proxy’
  7. Enter ’127.0.0.1′
  8. Enter port ’8080′
  9. Save changes by selecting ‘OK’

Fedora Linux:

  1. Open Google Chrome
  2. Select the wrench icon on the top right
  3. Select ‘Settings’
  4. Select ‘Show advanced settings…’
  5. Select ‘Change proxy settings…’
  6. Select ‘SOCKS Proxy’
  7. Enter ’127.0.0.1′
  8. Enter port ’8080′
  9. Save changes by selecting ‘OK’
Search Google for ‘my ip’ and take a look at what your IP address is now. Cool right? 

Exiting the SSH Tunnel

To exit the SSH tunnel, simply disable the SOCKS proxy within your browser.

Hope this helps, let me know if you have any suggestions in the comments below!

Incoming search terms:

  • http://www.zakochaniwfotografii.pl Alex

    Awesome tip Drew! I actually came to your site to check out the GitHub link you posted: http://fwp.drewsymo.com and it’s dead. I assume this site is built on that theme right?

    Thanks again,
    Alex

    • http://drewsymo.com Drew

      Thanks, Alex! I’m actually testing out the new framework (currently in beta) and will be releasing it shortly!

  • Erik

    too easy, thanks man!

    p.s. would it be possible to enable compression over a tunnel using the -c flag? havent tried it yet.

    • http://drewsymo.com Drew

      Hey Erik,

      SSH compression (-c) is already enabled in the snippet ;)

  • http://drewsymo.com Edaquinta

    One question… If I can’t see the SSH server because I have an http proxy (squid) in the middle?? Any App can do this? Sorry for my english.. I’m cuban.
    Greetings
    Edson Daquinta

    • http://drewsymo.com Drew

      Hi,

      This method will forward all traffic on port 80, which might conflict with your proxy. It might be a suggestion to disable your proxy first to avoid any issues!