SSH and telnet protocol handler for Firefox

I manage quite a lot of different computers, network devices, etc. As we are using an internal web based documentation system I thought it would be useful to be able to just click on ssh:// and telnet:// links and have Firefox open a terminal where I’d be connected to this specific machine.

As with most things computer related in the Internet era, someone else had already just done that. I modified his script a little bit so it’ll work with links specifying ssh keys and port :

  1. save the following zsh script into a file (let’s call it ~/.scripts/firefox-handler.zsh) (if you don’t have zsh, install it using your package manager or fix the script to use whatever shell you want).
    #makes -i $HOME/.ssh/id_rsa_foo work
    data=${data//%20/ }
    #/makes -i $HOME/.ssh/id_rsa_foo work
    /usr/bin/gnome-terminal -e "$proto $data"
  2. chmod +x ~/.scripts/firefox-handler.zsh
  3. in Firefox go to about:config and add the following two strings (right-click -> new -> string) and and put nothing as the value (for a yet unknown reason, it doesn’t work if you specify the path to your script right now)

Restart Firefox, you should now be able to click on ssh and telnet links and also type those URIs in your location bar and it should ask you with what application you want to open it, you can now browse to the location of the previously created script and check the box « don’t ask me again ». As an added bonus, you can also use those URIs as bookmarks which I find quite handy.