Open ssh URLs in chrome and firefox

If you are using some simple web applications that provides list of devices that you can connect using ssh it is useful to auto launch terminal with ssh connection started.

I am doing this on debian 9.5, chromium 69.0 and firefox 60.3.

First we need to setup xdg-open to handle ssh URLs. Create script that will start terminal together with ssh command:

cat /home/zzorica/scripts/

#gnome-terminal -e "ssh $d" &
terminator -e "ssh $d" &

To test you can run ./ ssh://user@ and it will launch another terminal (terminator in this case, or you can adjust for some other) with ssh connection open. You can put this script wherever you like. Next create desktop launcher so you can link it with xdg-open. Just make sure the path to previous script is correct.

cat ~/.local/share/applications/ssh-handler.desktop
[Desktop Entry]
Name=SSH Handler
Exec=/home/zzorica/scripts/ %u

Now we need to make sure that ssh URL are opened with this launcher. To do that put handler into your mimeapps.list. If you don't have this file create it. Default location is the same where you created .desktop file.

cat ~/.local/share/applications/mimeapps.list 

[Default Applications]

For test create simple html file and open it in both chromium and firefox. In ~/index.html put:

<a href="ssh://admin@">LINK</a>

If you click on link in Firefox you will choose SSH Handler for default application:

In chromium just select xdg-open:

That's it. Now whenever you have ssh link in your browser it will open terminal window and start ssh connection. In case of the link above it looks like this: