如何使用 ssh://user@ip liniks 更改 xdg-open 的作用

Dar*_*ren 4 ssh url

xdg open 忽略了我的指令。我找到了几个关于如何打开 ssh://user@ip 链接的主题(这些在我们的监控软件中)。我已经运行了以下命令:

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
Run Code Online (Sandbox Code Playgroud)

然而,当我尝试使用 xdg-open(就像 chrome 浏览器那样)时,它仍然尝试使用 sftp 代替...

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
Run Code Online (Sandbox Code Playgroud)

它似乎在 registery thingy 中设置正确

gconftool-2 -a /desktop/gnome/url-handlers/ssh
 command = /home/dankney/bin/SSH.handler %s
 needs_terminal = true
 enabled = true
Run Code Online (Sandbox Code Playgroud)

哦 - 这是 ls -alFh 和 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"
Run Code Online (Sandbox Code Playgroud)

是什么赋予了?

哦 - 顺便说一句 - 如果从命令行运行,shell 脚本确实可以工作......

小智 5

对于任何其他迟到者,此问题的更新版本 - 此链接对我来说是完整的解决方案:https : //lithostech.com/2014/04/get-ssh-protocol-links-working-in-ubuntuchromeunity/

基本上,在 shell 中执行以下命令来创建和重新分配 ssh 处理程序和 mime 类型:

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
Run Code Online (Sandbox Code Playgroud)