If you are using some simple web applications that provides list of devices that you can connect using ssh it is useful to auto launch terminal with ssh connection started.
I am doing this on debian 9.5, chromium 69.0 and firefox 60.3.
First we need to setup xdg-open to handle ssh URLs. Create script that will start terminal together with ssh command:
cat /home/allen/scripts/ssh-handler.sh
#!/bin/bash
echo $1 &>> /home/allen/result1
d=$(echo ${1#*ssh://}|awk -F: '{print $1}')
echo $d &>> /home/allen/result1
#gnome-terminal -e "ssh $d" &
/usr/bin/gnome-terminal -e "ssh -p 4422 $d" & &>> /home/allen/result1
Bash
Copy
To test you can run ./ssh-hander.sh ssh://user@192.168.1.1
and it will launch another terminal (terminator in this case, or you can adjust for some other) with ssh connection open. You can put this script wherever you like. Next create desktop launcher so you can link it with xdg-open. Just make sure the path to previous script is correct.
cat ~/.local/share/applications/ssh-handler.desktop
[Desktop Entry]
Type=Application
Name=SSH Handler
Exec=/home/allen/scripts/ssh-handler.sh %u
Icon=utilities-terminal
StartupNotify=false
MimeType=x-scheme-handler/ssh
Bash
Copy
Now we need to make sure that ssh URL are opened with this launcher. To do that put handler into your mimeapps.list. If you don't have this file create it. Default location is the same where you created .desktop file.
cat ~/.local/share/applications/mimeapps.list
[Default Applications]
text/html=chromium.desktop
x-scheme-handler/http=chromium.desktop
x-scheme-handler/https=chromium.desktop
x-scheme-handler/about=chromium.desktop
x-scheme-handler/unknown=chromium.desktop
x-scheme-handler/ssh=ssh-handler.desktop
Bash
Copy
For test create simple html file and open it in both chromium and firefox. In ~/index.html
put:
<a href="ssh://394e507ad03a4ad0cf381126@pam.***.com.au:4422">LINK</a>
Markup
Copy
If you click on link in Firefox you will choose SSH Handler for default application:
In chromium just select xdg-open:
That's it. Now whenever you have ssh link in your browser it will open terminal window and start ssh connection. In case of the link above it looks like this: