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.
2
I figured out a way to do it with just registry keys using a
– ubomb – 2015-04-09T21:42:44.587PowerShell
command. Here you go.@ubomb FYI, there's an answer from 2017 that looks similar to the
– jpaugh – 2019-08-07T19:43:06.187cmd.exe
version in your question. Perhaps it's different enough to overcome the limitations you faced before switching to PowerShell.