Another way to create quick-access SSH shortcuts

Oct 16, '06 07:30:03AM

Contributed by: Skurfer

I was initially using SSH shortcuts as described in this hint, but after using the hint for a while, I noticed some problems:

The solution was to use .term files for everything instead of ssh:// shortcuts.

My original objection to doing this was that .term files include every available Terminal setting. I like the ssh:// shortcuts because they would connect to a specific host, but use my default Terminal settings. By using .term files, I would have to recreate every single one to match the default settings if they ever changed …or so I thought.

It turns out that you can create a bare-bones .term file that contains only the settings you want to change from the defaults, and the Terminal will know what to do with it. In this case, I just wanted to specify the command that gets run in the new Terminal window. The script linked below will scan ~/.hosts and create a .term file for each machine listed there in ~/Library -> Application Support -> Terminal. I used PHP because that's what was quickest for me, but this wouldn't be hard to implement in other languages.

  1. Download the script [macosxhints mirror]
  2. Unzip the script and put it somewhere in your $PATH.
  3. Create ~/Library/Application Support/Terminal/ if it doesn't exist.
  4. Create a file in your home directory called .hosts and add the hostnames of machines you want to connect to (one per line).
  5. Run the mkterms script
Now you can access all these Terminal sessions by going to File -> Library in Terminal (after a relaunch), or better yet, using your favorite launcher-type thing (QuickSilver, LaunchBar, Butler, etc).

You could modify the script to add other options to the "shell command", such as a custom identity file or a different username. For example, the version I use is smart about how and when it creates .term files for root based on an LDAP database of machines we have where I work.

Comments (18)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20061009135231362