12

I would like to be able to click on SSH links that look like ssh://user@servername and have a gnome-terminal open that runs SSH inside of it.

After reading up on the XDG stuff I did the following:

I created a shell script in $HOME/bin/ssh-terminal with the following:

#!/bin/sh
dest=${1#ssh://}
gnome-terminal -e "ssh $dest" &

This works from the command line.

I created $HOME/.local/share/applications/ssh-terminal.desktop with:

[Desktop Entry]
Type=Application
Name=SSH Terminal
Exec=ssh-terminal %u
Icon=utilities-terminal
StartupNotify=false
MimeType=x-scheme-handler/ssh;

I ran update-desktop-database ~/.local/share/applications/

Now when I try to run xdg-open ssh://user@hostname I get the following error:

$ xdg-open ssh://[email protected]
gvfs-open: sftp://[email protected]/: error opening location: The specified location is not mounted

I don't want to open it as a sftp mount and I cannot seem to find where that is set!

Where do I go from here?

2 Answers 2

9

Writing a .desktop file is not enough. You also need to change the default setting for the mime type.

You can get the current default value with

 xdg-mime query default x-scheme-handler/ssh

and can change it with

 xdg-mime default ssh-terminal.desktop x-scheme-handler/ssh

The corresponding configuration file could be $HOME/.config/mimeapps.list or $HOME/.local/share/applications/mimeapps.list depending on your OS version.

2
  • Sorry about the late accept. This didn't work at the time I asked the question but I just tried it lately and it does now. Thanks. Commented Oct 28, 2014 at 21:54
  • 1
    To keep this excellent answer temporally relevant, in Ubuntu 18.04 LTS, the corresponding configuration file is now in $HOME/.config/mimeapps.list. At least for me, the one listed here in ~/.local/share/applications is 0 bytes. Commented Mar 4, 2020 at 18:43
1

None of this worked for me until I edited the following file and removed the SchemeAlias line on /usr/share/gvfs/mounts/sftp.mount

[Mount]
Type=sftp
Exec=/usr/lib/gvfs/gvfsd-sftp
AutoMount=false
Scheme=sftp
# SchemeAliases=ssh
DefaultPort=22
HostnameIsInetAddress=true
1
  • For anyone who encounters this (I did), you have to restart Gnome/Unity/Cinnamon for this to take effect. If you don't know how, restarting your computer should do the trick. Commented May 17, 2018 at 15:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.