Hey, just a heads-up that this content is based on an automatically imported version from our old CMS. If the formatting isn’t perfect, I’m sorry about that.
Just as a note to myself or anybody who is interested in it, feel free to use.
Often you come across hrefs linking to ssh://user@whatever:22. By default, Windows does not know what to do with this protocol. If you go to select the standard protocol handler for it, you only get redirected to the MS Store, offering you some expensive terminal apps you actually do not want to use. I, for myself, have been using the Pro version of MobaXterm for many years. MobaXterm has shell integration, but I never got it running right or being selectable as a protocol handler, unfortunately. But this is why I made this little method to actually make it working.
What you need to have:
A SSH program like Putty or MobaXterm or whatever you use. My example now is totally optimized for MobaXterm, but the principle is the same for every other SSH client; you just need to adjust the batch file accordingly.
1. Create a Batchfile
Use a folder where it can stay permanently, e.g., your MobaXterm SSH settings folder. Name it e.g., ssh_handler.cmd and put this into it:
@echo off
REM Simple SSH Link Protocol Handler for Win10
REM Can be used with Mobaxterm or easy adapted to any other ssh client
REM Public Domain feel free to use.
REM https://tcpip.wtf
REM -MG-
SETLOCAL
rem //removing ssh:// from call
SET TARGETHOST=%1
SET T2=%TARGETHOST:~6,-2%
rem searching Mobaxterm location
SET EXEC="%ProgramFiles%\Mobatek\MobaXterm\MobaXterm.exe"
IF EXIST %EXEC% GOTO CONNECT
SET EXEC="%ProgramFiles(x86)%\Mobatek\MobaXterm\MobaXterm.exe"
IF EXIST %EXEC% GOTO CONNECT
SET EXEC="%appdata%\Mobatek\MobaXterm\MobaXterm.exe"
IF EXIST %EXEC% GOTO CONNECT
echo MobaXterm EXE Not Found...
GOTO END
:CONNECT
echo Connecting to: %T2%
start "%T2%" %EXEC% -newtab "ssh -AC %T2%"
:END
2. Create a .reg file
This is just temporary to tell Windows about the new protocol handler. Name it whatever you like, e.g., custom-ssh-handler.reg, and put this in:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ssh]
@="URL: ssh Protocol"
"URL Protocol"=""
;Change this to your actual path of the previous generated Batch File
[HKEY_CLASSES_ROOT\ssh_custom_handler\shell\open\command]
@="C:\\your\\permanent\\path\\ssh_handler.cmd %1"
[HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications]
"SSH Custom handler"="Software\\Classes\\ssh_custom_handler\\Capabilities"
[HKEY_CLASSES_ROOT\ssh_custom_handler\Capabilities\UrlAssociations]
"ssh"="ssh_custom_handler"
;You can use any ICO File or just using mobaxterms Icon
[HKEY_CLASSES_ROOT\ssh_custom_handler\Application]
"ApplicationIcon"="\"C:\\Program Files (x86)\\Mobatek\\MobaXterm\\MobaXterm.exe\""
"ApplicationName"="Custom SSH Handler"
"ApplicationDescription"="Custom SSH Handler"
"ApplicationCompany"="Custom SSH Handler"
Before you save it, please change the path to your previously generated batch file. After saving, double-click it and agree to add it to the registry. Now the registry needs to reload; the simplest way is to either reboot your PC or log out of your account and log back in. After this, you need to open the Win10 Settings for Default Programs. Just press the WIN key and type “default”. If you scroll down on that dialog, you will find the option “Choose default Apps by Protocol”; open it and scroll down to SSH. Here you should now find the custom protocol handler we just created.
Example Screenshot of my German Win10: