Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How to SSH Tunnel

ssh tunnel putty cli security

  • Please log in to reply
No replies to this topic

#1 Sundance

Sundance

    CC Devotee

  • Validating
  • PipPipPipPipPipPip
  • 572 posts
  • Programming Language:C, Java, PHP, Python, JavaScript, Perl, PL/SQL, Transact-SQL, Bash, Others

Posted 23 February 2014 - 10:13 PM

How to SSH Tunnel!


Introduction

After reading many various posts on SSH tunneling I failed to find a decent one that really explained how to do it without giving you a wall of text to read, so I have decided to write a little tutorial!

What is an SSH Tunnel?
An SSH Tunnel is a way to send unencrypted information over an encrypted network, it is an excellent method for security and browsing the internet without restrictions that may be placed by your router for an example in the UK ISP providers forbid access to various torrent sites, using an SSH Tunnel you can circumvent this whilst also managing to keep your browsing information hidden from your ISP, however this should not be a method used to access illegal content, rather a way to stay anonymous on the internet, because privacy is important!

Legal
By following this tutorial you accept that I hold no responsibility to anything you do whilst SSH Tunneling, SSH Tunneling is not illegal and should only be used for your own privacy.

Requirements
A server (either remote or local is fine, this tutorial is for learning purposes however a remote server is better for seeing the magic happen)
A browser of your choice (For this tutorial I will be using Firefox/Iceweasel)
Either a terminal that supports the SSH command OR PuTTy

PuTTy can be found here

Step one - Start your terminal / PuTTy Client
Open up PuTTy OR your Terminal

PuTTy
F2ZJaPr.png

Terminal
7hWp6uw.png



Step Two - Configure the ports!
For PuTTy enter in your servers IP and port (by default the SSH Port is 22)
Then under the "connection" option on the left of PuTTy, click the right facing arrow that is next to "SSH"
Select "Tunnels" and you will be presented with the following screen

GFb0Ioh.png


In source port input a port of your choice for me it is 9090, then select "Dynamic" from the radio buttons and click "Add" to the right of "Source Port"

XVpbw9r.png


You will then see your PuTTy window looks something like this

ApRvqnX.png


For the Terminal use the following example replacing user with your servers main username (normally it will be root unless you have specified a different username) and then replace ip with your server's IP and then type -D and replace the XXXX with the port you would like to tunnel out of.
Vm5ZJhs.png
Here's an example of the terminal code and what it would look like for me

ssh kadence@192.168.0.1 -D9090

Then for PuTTy just press "Open" on the bottom right and enter in your password when prompted and move on to the next step!
For terminal just press enter and enter your password when prompted, once logged in move on to the next step!


Step Three - Configure your browser!


Open up your browser (For me it is Iceweasel but Firefox has an identical GUI.) and open up prefrences and navigate to Advanced > Network > Settings

zvBO1Lt.png


You will see this menu

1vwkggv.png

Select "Manual Proxy Configuration" from the radio buttons and inside "SOCKS HOST" enter in 127.0.0.1 and then in the box directly to the right enter in the port you designated earlier, for me it is 9090 you do NOT have to include the -D part if you are using a terminal / seen the -D pop up in PuTTy

Then press "OK".

After this is done, exit the "preferences" menu and try connecting to a site, to test it has worked type into google "What is my IP?" it should tell you the IP of your server you have SSH'd into.

If all is okay and you can see your servers IP then you are done!

Congratulations you have just done your first SSH Tunnel!



Notes
- You MUST leave your PuTTy window / Terminal open at all times, otherwise you will not be SSH Tunneled OR your browser will throw an error such as "The proxy server is refusing connections"
- This will only work for programs / applications you have changed the SOCKS proxy configuration to match.



If you have any questions feel free to PM me OR tweet me here!


  • 1

Please read the

FaQ & Guidelines






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download