Launch putty from browser

Posted on May 12, 2009. Filed under: Linux, Windows |

Launch PuTTY from Your Browser – Adding Procotols to Windows

For awhile now, I have wanted the ability to launch putty from a simple hyperlink.

PuTTY enables Windows users to access *nix machines through SSH. For many in the tech industry this tool is absolutely crucial. While it is fairly full featured, it is quite cumbersome for generic SSH use. One may say “Jon, all you need to do is run PuTTY, enter the host name you wish to connect to and provide a user name and password.” This process is certainly fine for a single SSH operation. This becomes quite a pain with multiple hosts at once.

What if there was a way to create a hyperlink which launches PuTTY? One would be able to launch PuTTY from email clients, browsers, spreadsheets, etc…
An example link would be: ssh://

What do we need to do?

  1. Register a new protocol (in our case, let’s call it “ssh”) to Windows’s registry.
  2. Create a batch file that can take in strings such as “ssh://” and massage them and pass them on to putty.exe
  3. Point the registry modification to that batch file.

One method of editing the registry is to create a .reg file, save it, right click it and select merge. The .reg file will then be merged with the registry. We will use this method. The key created can always be deleted by later from regedit.

Here is an example .reg file which points the protocol “ssh” to a batch file located at “C:/putty_util.bat” :

@="URL:ssh Protocol"
"URL Protocol"=""
@="\"C:\\putty_util.bat\" %1"

Now save ssh.reg locally, right click it, and select merge.

Note: You can create any new protocol by changing each “ssh” in this .reg file to whatever abbreviation you wish to use for your protocol. You will likewise want to change the string @=”\”C:\\putty_util.bat\” %1″ to point at whatever application you wish to use. In this case, we are using the application C:\putty_util.bat and passing in the first argument we receive to it. In the example of ssh://, we will be passing in the string “ssh://”

Unfortunately, PuTTY does not understand arguments which start off with “ssh://” . As a result, we must use a batch file (C:\putty_util.bat) to remove the “ssh://” and any other oddities. Here is the batch file for my box:

@echo off
set var=%1
set extract=%var:~6,-1%
"C:\Program Files\PuTTY\putty.exe" %extract%

set extract=%var:~6,-1% is telling us to remove the first 6 characters and the last character from var and place that value in extract. The removal of the first 6 characters is the removal of “ssh://”. We remove the last character as there seems to be a trailing slash present in the input to our batch file.

With extract holding just the hostname, we now execute putty.exe and pass in extract as an argument. In this case, putty.exe is located at C:\Program Files\PuTTY\putty.exe. Please change this to the location of your putty.exe. Save this batch file to C:\putty_util.bat

Once this is done, anytime you have a link such as ssh:// you should be able to simply click it and launch PuTTY.

I will have a followup post with instructions on how to accomplish the same with ssh in other operating systems.


External Links:




Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

9 Responses to “Launch putty from browser”

RSS Feed for John's Blog Comments RSS Feed

Great post !

Works like a charm and really solved my problem .

Thank you very much..

I tried to use the instructions but the cmd.exe is alive after the putty launch. so I modified the code in putty_util.bat

@echo off
set var=%1
set extract=%var:~6,-1%
CD C:\Program Files\PuTTY
start putty.exe %extract%

Thanks – works perfectly on Win2k8 x64 SP2… I use this to launch SSH and RDP sessions from a shortcuts page…

With the BAT above, the CMD window will stay open while the PuTTY/app stays open. Instead, change the command that launches PuTTY to use the START command, which will launch PuTTY in a new process, and allow the CMD window to close.

START “” “C:\Program Files (x86)\PuTTY\putty.exe” %extract%

This is really useful information. Just the stuff I was looking for. THANK YOU!

Thank you very much

Very cool, but how is this done for telnet ???? instead of SSH ??? – and also, how can you map the URL to a saved session in putty (i.e. with custom parameters for logging, window appearance and scroll back, etc.)?

This is a really useful blog. Thanks very much. In no time I had SSH set up to work, and after a little while I had Terminal Services working as well.

However, I was hoping to find your follow up post detailing how a MAC and even an Linux box could be set up the same?


I have loved this tweak for a long time. Unfortunately, it no longer works in Windows 10. Looks like Microsoft closed off the loophole and one has to purchase Metro Putty.

Hi John, how can move the logic of abstracting the arguments part to the content of .reg file ? if do like this. client environment no need the bat file to run. it’s better ! Thanks!

Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: