4

xdg open has ignored my directives. I have found several threads regarding how to open ssh://user@ip links (these are in our monitoring software). I have run the following commands:

gconftool-2 -s /desktop/gnome/url-handlers/ssh/command '/home/dankney/bin/SSH.handler %s' --type String
gconftool-2 -s /desktop/gnome/url-handlers/ssh/enabled --type Boolean true
gconftool-2 -s /desktop/gnome/url-handlers/ssh/needs_terminal --type Boolean true

Yet still when I attempt to use xdg-open (as the chrome browser does) it attempts to sftp instead...

xdg-open ssh://root@1.2.3.4
gvfs-open: sftp://root@1.2.3.4/: error opening location: The specified location is not mounted

It seems to be set correctly in the registery thingy

gconftool-2 -a /desktop/gnome/url-handlers/ssh
 command = /home/dankney/bin/SSH.handler %s
 needs_terminal = true
 enabled = true

Oh - here is the ls -alFh and contents of SSH.handler

ls -alFh /home/dankney/bin/SSH.handler 
-rwxrwxr-x 1 dankney dankney 133 Sep 18 21:16 /home/dankney/bin/SSH.handler*


cat /home/dankney/bin/SSH.handler*
#!/bin/bash
url=$1
protocol=${url//:*/}
machine=${url//*:\/\//}
machine=${machine%/}
/usr/bin/gnome-terminal -e "$protocol $machine"

what gives?

Oh - btw - the shell script indeed does work if run from command line...

5

For any other late comers, with more recent versions of this issue - This link was the total solution for me: https://lithostech.com/2014/04/get-ssh-protocol-links-working-in-ubuntuchromeunity/

Basically, execute the following in a shell to create and reassign the ssh handler and mime type:

xdg-mime default ssh.desktop x-scheme-handler/ssh
cat << EOF > ~/.local/share/applications/ssh.desktop
[Desktop Entry]
Version=1.0
Name=SSH Launcher
Exec=bash -c '(URL="%U" HOST="\${URL:6}"; ssh \$HOST); bash'
Terminal=true
Type=Application
Icon=utilities-terminal
EOF
1
  • 1
    I had to remove the escaping before $ to make it work, but otherwise all good on Fedora 29 here! Mar 20 '19 at 9:56
2

I wanted to change what xdg-open does with ssh:// links, to replace konsole with yakuake as handler. And this is what I did on my Kubuntu 15.10 (KDE Frameworks 5.15.0):

  1. found out what's the handler:

    $ xdg-mime query default x-scheme-handler/ssh
    ktelnetservice5.desktop
    
  2. located the handler on the disk:

    $ locate ktelnetservice5.desktop
    /usr/share/app-install/desktop/kio:ktelnetservice5.desktop
    /usr/share/applications/ktelnetservice5.desktop
    

    in my case I had to edit /usr/share/applications/ktelnetservice5.desktop

  3. edited the handler replacing

    Exec=ktelnetservice5 %u
    

    with

    Exec=/path/to/some/script.sh %u
    

where that script looks like this:

#!/bin/bash
qdbus org.kde.yakuake /yakuake/window toggleWindowState; qdbus org.kde.yakuake /yakuake/sessions addSession && qdbus org.kde.yakuake /yakuake/sessions runCommand "ssh `echo $1 | cut -d'/' -f3`"

and was given execute privileges:

chmod +x /path/to/some/script.sh

And that's it!

1

First you should set up a protocol handler, like this:

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

Then make a desktop entry file and put it somewhere like /usr/share/applications (perhaps it would be better to put it somewhere in ~/.config, though not sure where).

ssh.desktop:

[Desktop Entry]
Terminal=false
Type=Application
Exec=/home/dankney/bin/SSH.handler %F

Then next time xdg-open is called, it will use the ssh.desktop handler, which in turn will delegate the call to your shell script.

0

wrote a script support this url scheme:

ssh://[user[:pass]@]host[:port]

xdg-open-ssh:

use gnome-terminal or terminator open the ssh url,
if pass occur, use sshpass input password.
if pass err, failback to user input password.

https://github.com/yurenchen000/xdg-open-ssh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.