Jan 11, 2024 by Thibault Debatty | 846 views
https://cylab.be/blog/318/create-a-handler-for-opening-special-urls-like-ssh
Sometimes when using a web application you may encounter a special URL that does not start with http
or https
, like ssh://192.168.0.123
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.desktop
file in /usr/share/applications/
, for example /usr/share/applications/ssh.desktop
, with the following content:[Desktop Entry]
Version=1.0
Type=Application
Name=Open SSH URL
Comment=Open ssh://... URL
Terminal=true
Exec=gnome-terminal -- ssh %u
Icon=utilities-terminal
MimeType=x-scheme-handler/ssh;
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.desktop
file must executable:sudo chmod +x /usr/share/applications/ssh.desktop
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