HOWTO: Secure Firefox and IM with PuTTY

There are times when you want to connect to the Internet through unknown and/or insecure networks such as the local Panera or other WiFi hotspot. If you aren’t careful, you might make it all too easy for someone to sniff your connection using Ettercap.

One of the best ways to secure your connection is to use a VPN, but that isn’t always practical. So here’s a way to securely connect to the net using only an SSH client and a remote box that you control/trust.

Requirements:

  1. PuTTY* loaded on your local machine
  2. Remote host running OpenSSH (e.g. Linux box at home)
  3. Firefox (obviously)
  4. Gaim for all your IM needs

Just follow these steps…


1. Create a new PuTTY session
Run PuTTY and create a new session in PuTTY to connect to the remote host that is running OpenSSH. Fill in the hostname, the port (usually 22), make sure SSH is checked, give it a session name and hit Save:

PuTTY Session Config

2. Configure a secure tunnel
Click on “Tunnels” on the left and set up dynamic fowarding for a local port (e.g. 7070). Under “Add new forwarded port” type in 7070 for the source port, leave the destination blank, and check Auto and Dynamic. Then it the Add button. If you did it correctly, you’ll see D7070 listed in the Forwarded Ports box:

PuTTY Tunnels Config

That’s it for tunnels, as there is no need to create more than one. Remember to save your session profile in PuTTY so you don’t have to set up the tunnel next time.

3. Connect to the remote SSH box
Double click on the connection profile and type in your username and password when prompted.

4. Configure Firefox
Go to Tools, Options, General, and then click on Connection Settings…

Firefox connections

Check Manual Proxy Configuration, leave most of the fields blank, but fill in 127.0.0.1 for the SOCKS v5 host with a port of 7070 (or whatever you used in Step 2):

Firefox connection settings

5. Configure Gaim
Fire up Gaim and hit the Preferences button:

Gaim

Then select Network on the left and set up the Proxy Server. The Proxy Type should be SOCKS 5. The host is 127.0.0.1 and the port is 7070 (or whatever you chose in Step 2).

Gaim

There’s no need for a user or password. Then hit close.

6. Enjoy
That’s it. From now on, as long as you first log into the remote ssh host with PuTTY, your Firefox and IM traffic will be routed over a secure tunnel to the remote host and then out to the Net. Good stuff.

* Yes, PuTTY is available for Linux. It’s even in Portage!

Update (Email): Actually, the setup for Thunderbird to securely proxy your email traffic is pretty much the same as it is for Firefox.

And then type in 127.0.0.1 and your port number:

That’s it.

Update: Getting some linkage from Digg.

Corrections/Addendum:

  1. Note that this method will secure your connection between your remote location (e.g. WiFi hotspot) and the ssh host (e.g. Linux box at home). It is not secure from the ssh host to Internet. For the most part, that’s OK as it will provide reasonable protection from people running packet sniffers at the hotspot. But please recognize that if your ssh host is on your cable connection at home, your ISP can still (obviously) easily sniff all your packets.
  2. Quite a few people have correctly pointed out that DNS queries will still be “leaked” to the untrusted network. So the names of any sites you visit will still get logged.

    Now if you don’t mind people knowing what sites your are connecting to, then there’s nothing to worry about. But if are running the current version of Firefox and would like to protect that information, you can open the about:config page, and change network.proxy.socks_remote_dns to true.

    You can do the same thing in Thunderbird if you would like.

    For a greater level of security on all your connections, you should consider running a full VPN (see also: IPCop + OpenVPN HOWTO).

  3. As Nate pointed out in the comments, if you have the command-line version of OpenSSH already installed on your computer, you don’t need to mess with PuTTY. Just run ssh -D 7070 user@host.example.com and that will set up your tunnel. I’m not an Apple user, but I think OS X has everything you need.
  4. There are portable versions of Firefox, Gaim, and Thunderbird, and PuTTY runs from a USB drive. So using this method (unlike using OpenVPN) there is no need to install anything on the computer you are using. Quite handy if you are borrowing someone’s computer or you are in a school computer lab.
  5. How do you know if it’s working? Personally, I used SmartSniff to look at the packets and make sure they looked encrypted and were on the right ports. Of course, any packet sniffer would do.

    The other method (and I tried this one too) is to get all set up and running with the tunnels. And then after it is apparently working, kill PuTTY and see if you lose the connection.

    Of the two, the packet sniffer is the better way to go.

  6. Apparently Opera only does SOCK4. I didn’t personally try it, but this should work with SOCKS4 proxies as well as SOCKS5.
  7. SocksCap (non-commercial, home-use only) will let you run just about anything over a SOCKS5 proxy.

69 Responses to “HOWTO: Secure Firefox and IM with PuTTY”

  1. Nathan Says:

    Or, if you use linux, in a terminal type:

    ssh -D 7070 nathan@foo.bar.com // This is the remote address

    And follow the rest of the tutorial.

  2. John Says:

    Heh. Good call. That’s easy enough. :)

  3. Austoon Daily » HOWTO: Secure Firefox and IM with PuTTY Says:

    [...] One of the best ways to secure your connection is to use a VPN, but that isn’t always practical. So here’s a way to securely connect to the net using only an SSH client and a remote box that you control/trust . [...]

  4. bhaskar Says:

    To add to what nathan suggested, on linux do

    ssh -qTfnN -D 7070 remotehost.

    All the added options are for a ssh session that’s used for tunneling.

    -q :- be very quite, we are acting only as a tunnel.
    -T :- Do not allocate a pseudo tty, we are only acting a tunnel.
    -f :- move the ssh process to background, as we don’t want to interact with this ssh session directly.
    -N :- Do not execute remote command.
    -n :- redirect standard input to /dev/null.

    In addition on a slow line you can gain performance by enabling compression with the -C option.

  5. Pretentious nonsense » SSH tunneling Says:

    [...] I noticed a nice secure tunneling tutorial over at digg that uses putty. It might be useful to someone.   [...]

  6. Nathan W Says:

    if you type in ssh -fD 7070 bla@bla.com
    this will make the tunnel run as a background service, so you don’t have an empty terminal open

  7. HOWTO: Secure Firefox/IM/email from anywhere with PuTTY at Morad’s Bloggie Says:

    [...] Quick, step-by-step HOWTO to set up secure, encrypted tunnels for web browsing, instant messaging, and email from anywhere. No need to set up a VPN. Great for working from hotels and coffee shops!read more | digg story [...]

  8. Photar Says:

    You should also mention DNS leakage.

  9. joechang Says:

    If you’re on Windows, even easier is to download and use bitvise tunnelier. stays open and minimizes into the tray, and will even reattempt connection should you be dropped. as good as it gets for a background ssh tunneler for windows. google ‘download bitvise tunnelier’ .

  10. weregeek Says:

    Don’t forget to make sure that you don’t leak DNS queries:

    (quoted from metropipe.net)

    ONLY use Firefox 1.5.0.2, go to about:config and set network.proxy.socks_remote_dns to true. This method only protects Firefox from the problem.

  11. FireFox Hacker -- Firefox Hacks, Tweaks, Tutorials and more » Securing Firefox With Putty Says:

    [...] Howto Secure Firefox with Putty [...]

  12. analogAI Says:

    For a GUI-less version that does basically the same thing, you can use plink in the PuTTY package. On the windows platform, you can combine it with VBScript WshShell to bring up a GUI prompt for password.

    plink.exe -ssh -2 -batch -v -C -N -L ” & localHost & “:” & localTunnelPort & “:” & remoteHost & “:” & remoteTunnelPort &” -pw ” & remoteGatewayPassword & ” ” & remoteGatewayUserName & “@” & remoteGateway & ” > ” & logName & ” 2>&1″

  13. Random Guy Says:

    In Firefox and Thunderbird, you need to set the network.proxy.socks_remote_dns option to true. Otherwise you will have DNS leakage and DNS will not resolve when proxyied into a private network. I don’t use the other apps, so I don’t know how they handle SOCKS v5 (or 4A) name resolution.

  14. Bog Says:

    Can you do this with VNC?

  15. Can U Bulee Dat?! » Blog Archive » HOWTO: Secure Firefox/IM/email from anywhere with PuTTY Says:

    [...] Quick, step-by-step HOWTO to set up secure, encrypted tunnels for web browsing, instant messaging, and email from anywhere. No need to set up a VPN. Great for working from hotels and coffee shops!read more | digg story [...]

  16. Code Thread » Cool stuff Says:

    [...] Came across this link on Digg. Talks about how to use PuTTY to tunnel connections over SSH to access the net through a trusted box rather than on an unsecured wireless network. Pretty easy step-by-step instructions with screenshots. [...]

  17. zean.no-ip.info » HOWTO: Secure Firefox and IM with PuTTY Says:

    [...] http://thinkhole.org/wp/2006/05/10/howto-secure-firefox-and-im-with-putty/   [...]

  18. web-ology.com » links for 2006-05-23 Says:

    [...] import this. » Blog Archive » HOWTO: Secure Firefox and IM with PuTTY (tags: putty security)   [...]

  19. Chrono Cr@cker Says:

    Very interesting article. Good read. Must read for users who access the net from many places.

    Mozilla Firefox has a lot of disadvantages though.

  20. All Dugg » Blog Archive » HOWTO: Secure Firefox/IM/email from anywhere with PuTTY Says:

    [...] Quick, step-by-step HOWTO to set up secure, encrypted tunnels for web browsing, instant messaging, and email from anywhere. No need to set up a VPN. Great for working from hotels and coffee shops!read more | digg story Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages. [...]

  21. anonymono Says:

    It does not work for me, what am I doing wrong? I have SUSE 10.1 with OpenSSH installed (/etc/init.d/sshd status returns “running”) and I have followed all the steps. Firefox tells me that it can’t connect to the proxy :-?

  22. sshlog » 20060523 Says:

    [...] HOWTO: Secure Firefox and IM with PuTTY - 利用 Putty 建立 SSH Tunnel,然後透過此Tunnel對外連線。 [...]

  23. El Pato Sánchez!!! » Archivo del weblog » HOWTO: Secure Firefox and IM with PuTTY Says:

    [...] http://thinkhole.org/wp/2006/05/10/howto-secure-firefox-and-im-with-putty/ [...]

  24. The Completely Evil Blog » Blog Archive » HOWTO: Create secure Firefox and IM sessions with PuTTY Says:

    [...] HOWTO: Secure Firefox and IM with PuTTY [...]

  25. duder Says:

    Hi-

    Checking it out with SmartSniff, I fully see all the packets. How can I be ensured of encryption? What did I do wrong?

  26. burpee Says:

    Or even better yet, just connect through ssh to your remote box and use elinks for web browsing and a text based instant messenger client for chatting.

  27. Do No 3vil » Blog Archive » How to surf securely in a wifi hotspot Says:

    [...] On a linux host you could to the following: ssh -qTfnN -D 7070 remotehost instead of using putty.  Thanks to thinkhole for this great article [...]

  28. Jules Says:

    A warning here:

    The most common problem with using public computers for secure access is NOT packet sniffing (which this protects against) - but rather KEYSTROKE CAPTURE - which this does NOTHING to protect.

    J.

  29. links for 2006-05-24 at protocol7 Says:

    [...] HOWTO: Secure Firefox and IM with PuTTY (tags: security firefox putty gaim SSH) // Used for showing and hiding user information in the comment form function ShowUtils() { document.getElementById(”authorinfo”).style.display = “”; document.getElementById(”showinfo”).style.display = “none”; document.getElementById(”hideinfo”).style.display = “”; } function HideUtils() { document.getElementById(”authorinfo”).style.display = “none”; document.getElementById(”showinfo”).style.display = “”; document.getElementById(”hideinfo”).style.display = “none”; } [...]

  30. THE Blog » Blog Archive » HOWTO: Secure Firefox/IM/email from anywhere with PuTTY Says:

    [...] Source: http://thinkhole.org/wp/2006/05/10/howto-secure-firefox-and-im-with-putty/ [...]

  31. Crypto Resync Says:

    Secure Firefox and IM with PuTTY…

    Using public WiFi, while nice because it is free, is a sandbox for hackers to capture data that you might have otherwise thought was secure. Any black hat can use freely available tools that can sniff the data leaving your computer and capture that in…

  32. Anthony Says:

    I typically just ssh into my machine and browse with links or elinks.

    Much faster. But this is useful.

    Thanks!

  33. J3satan Says:

    Sounds like a cool idea but why not just use tor or torpark on a thumb drive to take care of your anonymity? You can use tor with gaim and the PGP plugin to encrypt aim traffic.

  34. John Says:

    J3:

    (1) For my purposes, I don’t really care about anonymity.

    (2) I tried Tor, and found it to be quite slow. Certainly slower than a non-Tor setup.

    That said, Tor may be a good solution for people, depending on the needs/problem to be addressed.

  35. Specfuckingtacular » Links of the Week Says:

    [...] How To: secure Firefox and IM with PuTTY (when connected to a public/unsafe network) [...]

  36. Unofficial DreamHost Blog Says:

    More Tips for Secure Communication…

    Previously I’ve written about how to use SFTP, SSH and SSL to secure your web surfing experience. One of the tips was to use PuTTY as your SSH client to create an encrypted connection to DreamHost’s servers.
    thinkholelabs now features a gre…

  37. Chris Dzombak » Blog Archive » SSH, Tunneling, and Dreamhost Says:

    [...] Resources for tunneling your traffic through your Dreamhost server using SSH. Here, here, here, and here. [...]

  38. Kirill Ponomarew (krion) blog mess » Daily del.icio.us bookmarks for 2006-05-25 Says:

    [...] Secure Firefox and IM with PuTTY (tags: browser firefox putty security ssh tunnel vpn) [...]

  39. Bilange’s Blog - What’s up? » Meebo: connexion sur MSN, via Internet Explorer/Firefox Says:

    [...] Pour se connecter à une machine Linux, la plupart des gens utilise SSH, qui est à la base une connexion sécurisée sur laquelle on peut faire du transfert de fichiers, terminal/console/shell, et j’en passe. Cet article indique comment configurer Putty (un programme ssh pour Windows) pour se connecter sur une machine ET configurer un proxy pour les programmes exécutés local (comme MSN), pour les rediriger vers la connexion SSH. [...]

  40. -TMA-1- » Blog Archive » links for 2006-05-27 Says:

    [...] HOWTO: Secure Firefox and IM with PuTTY (tags: Tech HOWTO SSH Security Putty) [...]

  41. Life, it is a Travesty… » links for 2006-05-24 Says:

    [...] import this. » Blog Archive » HOWTO: Secure Firefox and IM with PuTTY Very good tutrorial with comments that make sense. This is good for the paranoid among us. (tags: ssh putty vpn terminal telnet mail im) [...]

  42. fredyubuntu Says:

    the proxy doenst work with GAIM…i dnt know why…it says it cant connect to it.

  43. nostrich.net » Blog Archive » OpenSSH on a Windows Box Says:

    [...] I read a great tip recently that told you how to securely connect to the Internet through an unknown or insecure network using SSH tunnelling, but it does require you to have access to a host running OpenSSH. Simple on Linux, not so simple on Windows. But it is possible, here’s how. [...]

  44. Vincent Says:

    wow, this is pretty cool. thx for the information

  45. Sacrosanct Security Solutions » Blog Archive » HOWTO: Secure Firefox/IM/email from anywhere with PuTTY Says:

    [...] read more | digg story [...]

  46. Dylan K Says:

    network.proxy.socks_remote_dns only works on plain proxies, once you start using SSH, it doesn’t work very well, because DNS uses UDP, and SSH can’t forward UDP… just try it for yourself. I’m using Firefox 1.5.0.4. I’ve tried this with PuTTY and with a few other programs, always the same results with Ethereal:
    http://img152.imageshack.us/img152/7194/dns5ib.jpg

    If anybody knows how to get around this (besides Privoxy)… let me know. :)

  47. Tristor Says:

    Instead of using hidden settings in Firefox/Thunderbird to keep from leaking your DNS queries, you can use Privoxy and set it up to connect to the SSH tunnel, and then from there set everything to use Privoxy. Privoxy will do your DNS queries through the tunnel.

  48. Tristor Says:

    ^^Dylan:

    There isn’t really any way around it other than using Privoxy or encapsulating your DNS queries in some fashion so they can be sent over the tunnel normally (which is what Privoxy does). But since Privoxy is free and easy to setup, I don’t see why there is any problem with using it.

  49. Adam Platti’s Blog » Blog Archive » Reasonably Secure Internet Access on Public WiFi Says:

    [...] I found some great info about how to surf the web at WiFi hotspots with some extra security.   You need a remote server somewhere running OpenSSH and an SSH client like PuTTy.    If you set it up (it’s easy), it will protect you against some jack ass at the internet cafe running Wireshark, or some other network protocol analyzer. [...]

  50. Security » HOWTO: Secure Firefox/IM/email from anywhere with PuTTY Says:

    [...] Quick, step-by-step HOWTO to set up secure, encrypted tunnels for web browsing, instant messaging, and email from anywhere. No need to set up a VPN. Great for working from hotels and coffee shops!read more | digg story [...]

  51. Alexey Says:

    With help of free client Hummingbird SOCKS V8.001 it’s easy to socksify any Windows program using PuTTY’s tunnel, including Opera and any other program, that don’t support socks proxy natively.

  52. ziegs2020.com | secure your shit Says:

    [...] No Related Posts a nice article on keeping your IMs and browsing private when you’re on wireless. via thinkhole « « gmail | [...]

  53. Code Thread :: Cool stuff Says:

    [...] Came across this link on Digg. Talks about how to use PuTTY to tunnel connections over SSH to access the net through a trusted box rather than on an unsecured wireless network. Pretty easy step-by-step instructions with screenshots. [...]

  54. groove10 Says:

    Why isn’t this an actual extension in Firefox.

    Something that would configure all the details and remain “embedded” in FF? A port-forward with an SSH connection is all that’s needed.

    Are there some licensing issues somewhere that I don’t know about?

    I would hope that this extension would be easy enough to use such that the more novice end users who are concerned about security would be able to easily set up a tunnel and encryption without having to download too many other programs or mess with the command-line.

    Just a thought. I’m not a programmer, otherwise I’d try to do it myself.

  55. Lars Says:

    Has anyone found a SIP client that can be run this way? I’ve been looking like mad for a socks enabled SIP client but cant seem to find any…
    It would be great to be able to SSH tunnel to the PBX from any net.

  56. mmb » Blog Archive » links for 2007-02-16 Says:

    [...] how to set up a secure web proxy using putty and Firefox also change about:config network.proxy.socks_remote_dns (tags: howto web proxy ssh putty firefox) [...]

  57. Matt Van Dusen Says:

    @Tristor: …and once you’re done setting up Privoxy, PuTTY, Firefox, etc. on whatever remote computer you’re using, you’re time’s up…

    Personally, I don’t care if someone gets kicks from watching what web sites I’m visiting, or if they grab my data going over the line, Anything I need secured is already running 128-bit or 256-bit SSL (for web sites) or I conduct those activities by simply PuTTYing into the server (for mail/config).

  58. Firewall an der Schule - Apfeltalk Says:

    [...] permalink ssh -qTfnN -D 7070 remotehost hier gibts ein paar infos in den kommentaren zu dem thema.. aber ohne server mit shell zugriff bringt das leider nichts. [...]

  59. 2ge Says:

    I found freecap - it is something like sockscap for windows, you can socksify any windows program, opera has no socks support (no socks4 as you wrote).

  60. totally superfluous rambling » Blog Archive » WPA Can also be Cracked!! Says:

    [...] I’ll be trying to figure out how to use secure email protocols.  I’ve already tried to switch to using SCP instead of Dreamweaver or Filezilla to transfer files (and using Secure FTP when in Dreamweaver).  So it’s pretty much just a change in how I do things.  And just for my memory more than anything - here is a link to securing Firefox and IM. I’ll be looking into doing that. [...]

  61. Foxhop Says:

    Not only does this tunnel out for privacy, but its an awesome method of bipassing annoying firewalls and site blockers. : )

  62. fulanpeng Says:

    I set up the Firebox. I setup the ssh server on the server side and Putty on the client side. What should I do with the ssh server? Do I have to issue the command when I have logged into ssh server with the Putty?

    After I am able to log in to the ssh server with Putty, then I set up the Firebox. Now the Putty part is confusing. Do we have to log into the ssh server while we are using Firefox? Please help me out! Now my Firefox saying the proxy server is refusing connection.

  63. fulanpeng Says:

    I figured out. Actually there are only 3 portions of the job:
    1, set up the ssh server
    2, set up the client, putty or ssh
    3, set up the browser.

    To set up the tunnel, it is done in the second step. As long as the user be able to login from remote, the ssh server job is done. Do not need issue the command on the server side to talk to the client(ssh or Putty). The tunnel is built by the client on the client’s machine. This is hard to understand. Usually, on the server side, the server has to do something to cooperate with the client.
    Sounds like Firefox won’t work with Socks4. We have to explicitly tell Firefox to use Socks5.

    Now my tunnel is working. The big problem is:
    which DNS the browser is using? When I input a wrong DNS on the TCP/IP property, browser won’t find the site. This seems that the browser is still using the local DNS. How do I know the browser is really using remote DNS. I have done the about:config part.

  64. fulanpeng Says:

    On the command window, you can fire this command. Then configure Firefox to listen to 127.0.0.1:7000

    plink.exe -D 7000 your_login@the_ssh_server -P 443 -N -C -pw “your_pass phrase” -i “the_private_key_file_you_created_by_putty_keygen”

    assuming you have already put the public key in your home/.ssh directory. Name it as authorized_keys.

  65. fulanpeng Says:

    I tried out FreeCap working with Putty ssh tunnel for Skype. Skype is extremely aggressive. It can penetrate any firewall without any help of DNS, local or remote. If you just tell Skype to use your Socks proxy, it won’t work. It will go beyond of your proxy and find some other port to reach outside. If you put Skype in your FreeCap, Skype cannot find any other port except the proxy you set up. This way, all of your Skype traffic will go through your Socks tunnel. Also you can grad Firefox into FreeCap. MS Internet Explorer won’t work with FreeCap and Putty Socks tunnel. It uses the local DNS and by pass your tunnel.

    Now if you fire the command:
    plink.exe -D 7000 your_login@the_ssh_server -P 80 -N -C -pw “your_pass phrase” -i “the_private_key_file_you_created_by_putty_keygen”,
    the man in the dark world will have hard time to read your traffic!

  66. S Says:

    I’ve used SSH tunnel with FF for a while, never knew about the DNS leakage. Kinda worried now. Anyway, I also wondered, why do you have to choose SOCKS(5)? Why not just use http proxy, use same proxy for all protocols? Is this leaking info too?

  67. Will Boyce Says:

    Hmm, I did all of the above (well, the necessary steps) as youtube is blocked from my new office, yet is a vital part of most news stories (especially on theregister.co.uk).. So, simple enough, ssh -D.. No joy! ssh hostname -L 8080:proxy:proxy_port works fine, but ssh hostname -D 8080 doesn’t work at all.. Firefox can connect to the proxy, but never loads anything. Anybody got any ideas about this odd behaviour?

  68. John Says:

    I have this working no problem. However, it will not work from my office. I can setup the SSH connectin from just about any network, but when I try it at work, putty can’t connect to my server….. is there a setting that I can adjust? How can my office admins block ssh on the network?

  69. Putty, SSH, Tunneling (Proxy) by JM Says:

    [...] very helpful tutorial on how to use Putty to Tunnel your Firefox activities through an SSH connection — essentially, make it look like your machine is wherever your server [...]

Leave a Reply