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://user@thiscomputer.com and telnet://thisdevice.com 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 :
- 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).
#!/bin/zsh url=$1 proto=${url//:*/} data=${${url//*:///}%/} #makes -i $HOME/.ssh/id_rsa_foo work data=${data//%20/ } data=${data//$HOME/$HOME} #/makes -i $HOME/.ssh/id_rsa_foo work /usr/bin/gnome-terminal -e "$proto $data"
- chmod +x ~/.scripts/firefox-handler.zsh
- in Firefox go to about:config and add the following two strings (right-click -> new -> string) network.protocol-handler.app.ssh and network.protocol-handler.app.telnet 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.