Create a handler for opening special URLs like 'ssh://'

Jan 11, 2024 by Thibault Debatty | 239 views

Linux Sysadmin

Sometimes when using a web application you may encounter a special URL that does not start with http or https, like ssh:// for example. On a mobile device, your phone will usually open the appropriate application to handle this URL. Here is how to achieve the same on a Linux computer.

.desktop file

  1. Create a .desktop file in /usr/share/applications/, for example /usr/share/applications/ssh.desktop , with the following content:
[Desktop Entry]
Name=Open SSH URL
Comment=Open ssh://... URL
Exec=gnome-terminal -- ssh %u

Most lines are self-explanatory. The two import lines are:

  • Exec=gnome-terminal -- ssh %u that shows the command to execute. In this example we open a terminal to execute ssh, and %u is the actual URL. Other parameters can be found on the desktop entry reference page
  • MimeType=x-scheme-handler/ssh; that states that this entry should be used (executed) to handle ssh:// URLs
  1. The .desktop file must executable:
sudo chmod +x ~/usr/share/applications/ssh.desktop
  1. Finally, you must update the desktop entries cache:
sudo update-desktop-database


If you have an SSH server installed on your machine, you can now test your handler with a link like this one:



This blog post is licensed under CC BY-SA 4.0

This website uses cookies. More information about the use of cookies is available in the cookies policy.