Firefox Telnet Handler

Firefox, by default, doesn’t have a telnet handler. This is quite annoying because it means that whenever you click on a telnet link, you will get the following message:

"Firefox doesn't know how to open this address, because the protocol (telnet) isn't associated with any program."

As a network engineer, you probably use telnet every now and then so it would be nice if these links are clickable so you don’t have to copy and paste them into your terminal.

In order to fix this, we’ll create a script that launches telnet and connects to the IP address or hostname that you clicked on in the browser, and we will tell Firefox to use this script.

I will create a new folder in my home folder where I’ll store the script:

# mkdir ~/scripts

We’ll create a new filename for the script:

# vim ~/scripts/telnetfirefox.sh

Paste the following into the VIM text editor:

#!/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/mate-terminal -e "$proto $data"

In my case, I’m using mate-terminal (the default terminal for Linux Mint), but you can change this line if you are using the Gnome terminal or something else like xterm. Save it and make it executable:

# chmod +x telnetfirefox.sh

This script requires the ZSH shell, so if you don’t have it, install it:

# sudo apt-get install zsh

The script is ready but we still need to make some changes to Firefox. Start Firefox and type about:config in the address bar.

Click on “I’ll be careful, I promise!”. Do a right mouse click, select New, and choose Boolean.

Call the new entry “network.protocol-handler.expose.telnet” (without quotes) , select False, and click on OK.

Restart Firefox and open a webpage that shows you some telnet links. For example, the BGP4.as looking glass servers webpage. Click on a telnet link, and Firefox will ask you what application to use. Click on Browse and select the script file that you just created.

If everything went ok, it should now open a terminal and telnet to the correct hostname / IP address!

Thanks to Jonathan Ernst for providing this script.

Tags: ,


Forum Replies

  1. Great tutorial, Rene.

    Is it possible to do with linux/chrome as well? Not sure what you do for network.protocol-handler.expose.telnet in chrome.

    merci d’avance

  2. Hi Chris,

    It should be possible but I haven’t tried it yet…when I have some time I’ll give it a shot.

    Rene

  3. im struggling with ubuntu 20.44 + firefox :
    ive made and script to use a securecrt session, when i do double click in one node doesnt connect

    NOTE : i replaced the real ipv4 add (is a public one) with x.x.x.x

    sep 11 19:24:37 HP-Z440 firefox_firefox.desktop[14338]: /home/jjc/Documents/Tunel_SSH.sh: line 2: telnet://x.x.x.x:50717: No such file or directory
    sep 11 19:24:37 HP-Z440 firefox_firefox.desktop[14336]: /home/jjc/Documents/Tunel_SSH.sh: line 6: exec: SecureCRT: not found
    sep 11 19:24:39 HP-Z440 firefox_firefox.desktop[14347]: /home/jjc/Documents/Tunel_SS
    ... Continue reading in our forum

Ask a question or join the discussion by visiting our Community Forum