Quick Tip: Using PuTTY to Handle telnet:// URL Links in Linux

Quick Tip: Using PuTTY to Handle telnet:// URL Links in Linux

This setup allows PuTTY — a popular SSH and Telnet client — to automatically open telnet:// links from web browsers, file managers, or other applications in Ubuntu (and other Linux desktop environments such as GNOME, KDE, or XFCE).

By creating a custom .desktop launcher and a small wrapper script, Ubuntu’s desktop system recognizes telnet:// URLs and launches PuTTY with the correct host and port information.

If you have not already installed PuTTY, use your system's package manager or CLI.

How It Works

When you click a link such as:

telnet <host>:<port> 

the URL telnet://<eve-ng-host>:<port> gets passed to PuTTy. An important note here though.
You may get connection refused in PuTTY. That is because PuTTY doesn’t natively parse that full URL — it expects:

putty -telnet <host> <port>

So you need a small layer in between to split the URL and port before passing them to PuTTY.

Here’s how you can do it cleanly. We are going to create a wrapper script.

Step 1: Create a small script
Create a file named /usr/local/bin/putty-telnet-wrapper

#!/bin/bash
# Handle telnet:// URLs from desktop entries and browsers
url="$1"

# Strip the telnet:// prefix if present
url="${url#telnet://}"

# Extract host and port
host="${url%%:*}"          # everything before the first colon
port="${url#*:}"           # everything after the first colon

# If host and port are the same, no port was given → default to 23
if [ "$host" = "$port" ]; then
  port=23
fi

# Launch PuTTY
exec /usr/bin/putty -telnet "$host" "$port"

Make it executable

sudo chmod +x /usr/local/bin/putty-telnet-wrapper

Create a .desktop file named ~/local/share/applications/telnet.desktop

[Desktop Entry]
Version=1.0
Name=Telnet
GenericName=Telnet
Comment=Telnet Client
Exec=/usr/local/bin/putty-telnet-wrapper %U
TryExec=/usr/local/bin/putty-telnet-wrapper
Terminal=false
Type=Application
Categories=TerminalEmulator;Network;Telnet;Internet;BBS;
MimeType=x-scheme-handler/telnet;
X-KDE-Protocols=telnet
Keywords=Terminal;Emulator;Network;Internet;BBS;Telnet;Client;
  • When a user clicks a telnet:// link (e.g. telnet://foo.bar:2023),
    the desktop environment replaces %U with that URL.
  • The wrapper strips the scheme (telnet://), splits the host and port, and runs:
/usr/bin/putty -telnet <host> <port>