Make ssh:// links open with PuTTY
Solution 1:
There is a Putty fork named Kitty, it's website includes instructions for doing exactly what you want.
It does involve registry changes but these are accomplished by downloading a .reg file and clicking on it in windows explorer (with admin privileges I guess).
Solution 2:
PuTTY unfortunately does not associate itself with the ssh://
URLs.
You can associate an application with a protocol manually. See the MSDN article Registering an Application to a URI Scheme.
Basically you add a registry key like:
[HKEY_CLASSES_ROOT\ssh]
@="URL: SSH Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\ssh\DefaultIcon]
@="\"C:\\Program Files (x86)\\PuTTY\\PuTTY.exe\",0"
[HKEY_CLASSES_ROOT\ssh\shell]
[HKEY_CLASSES_ROOT\ssh\shell\open]
[HKEY_CLASSES_ROOT\ssh\shell\open\command]
@="\"C:\\Program Files (x86)\\PuTTY\\PuTTY.exe\""
Though the above passes a whole URL to the PuTTY command-line. And PuTTY does not understand the ssh://
prefix. So you would have to add a wrapper script that strips the ssh://
and passes only a user and a host to PuTTY.
For that see:
https://johnsofteng.wordpress.com/2009/05/12/launch-putty-from-browser/
Another way is using WinSCP. It registers itself to handle the ssh://
URL and opens the session specified by the URL in PuTTY.
(I'm the author of WinSCP)
Solution 3:
See this: https://gist.github.com/sbiffi/11256316
I wanted a solution which does not need to change putty.
It associates a visual basic script to ssh:// and telnet:// URLs, which parses the URL and launches putty using standard parameters like putty.exe -ssh -l login.
2 additional advantages: – Password can be passed in URL also for auto authentication – No need to change putty, thus adapted to all patches.
Solution 4:
Here's a registry class that'll remove the ssh:// and trailing (actually, all) / from the URI before passing it to PuTTY so PuTTY can directly open it:
Per User:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\ssh]
@="URL:ssh Protocol"
"URL Protocol"="ssh://"
[HKEY_CURRENT_USER\Software\Classes\ssh\shell]
[HKEY_CURRENT_USER\Software\Classes\ssh\shell\open]
[HKEY_CURRENT_USER\Software\Classes\ssh\shell\open\command]
@="cmd /V:ON /c set params=%1 && set params=!params:ssh://=! && start \"PuTTY\" \"c:\\Program Files (x86)\\PuTTY\\putty.exe\" \"!params:/=!\""
And, for everyone on the system:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ssh]
@="URL:ssh Protocol"
"URL Protocol"="ssh://"
[HKEY_CLASSES_ROOT\ssh\shell]
[HKEY_CLASSES_ROOT\ssh\shell\open]
[HKEY_CLASSES_ROOT\ssh\shell\open\command]
@="cmd /V:ON /c set params=%1 && set params=!params:ssh://=! && start \"PuTTY\" \"c:\\Program Files (x86)\\PuTTY\\putty.exe\" \"!params:/=!\""
Change the file path based off of your needs.
/V:ON is the same as 'SetLocal EnableDelayedExpansion'
/c runs the command
I set params to the paramater which is 'ssh://domain.tld/'. Then I strip the 'ssh://' from it with the '!params:ssh://=!', which is a find-replace for 'ssh://' to '' on the variable params. I assign that back to params, now params = 'domain.tld/'. I then pass it to putty and do another find-replace to replace '/' with '' to remove the trailing slash that Windows puts on, leaving 'domain.tld' which PuTTY can use.
This lets me process it all in the command entered in the registry entry. It doesn't do any sort of sanitizing at all and is easily exploitable (Ex. ssh://&¬epad opens notepad) so you might want to change the URI to something only you know.