ssh Shortcuts using .ssh/config

To create an ssh shortcut, add the following text (adopted to your setup) to .ssh/config:

# You can add multiple blocks like this to your .ssh/config
Host rudolf
Hostname rudolf-web.net
Port 22
User rudolf
Protocol 2
Compression yes
ServerAliveInterval 15
ForwardX11 no
#LocalForward 20001 8.8.8.8:80

To connect to that host via ssh you can now simply type the following on the terminal:

ssh rudolf

Now to get a shortcut, mark the following text and drag it to the desktop:

ssh://rudolf

It will create a connection shortcut file. If you move this file to a subfolder of the Applications folder called terminal connections you have a convenient way to access your SSH connections via Spotlight.

In our example, the result of the drag-n-drop action will be a file called rudolf.inetloc with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>URL</key>
    <string>ssh://reliable</string>
</dict>
</plist>

When you double-click that file the connection is opened. But the details are kept in the Mac OS resource fork: check this using cat rudolf.inetloc/..namedfork/rsrc. So if you copy the file, do it either on the command line using cp or delete the resource fork using: cat /dev/null >rudolf.inetloc/..namedfork/rsrc

resources

Comments