rentzsch.com: tales from the red shed

ssh:// protocol handler

Mac OS X
Sanford Selznick clued me into a little bit of hidden functionality in Mac OS X: Terminal.app is registered as the protocol handler for ssh://. Here's an example: ssh://localhost. If you're on Mac OS X, clicking on this link should launch Terminal.app (if it's not already running), which will spawn a new window holding a new ssh session.

That means every well-written app that can open URLs can start a ssh session. This includes apps like Safari, Mail.app and the Finder. It's also how you can make PasswordWallet automatically start a ssh session when you click on a password entry (hint: use the entry's "URL" field and click on the globe icon).

But wait, there's more. You can add switches and parameters to the ssh invokation with a little URI escaping. For example, opening ssh://localhost%20-l%20wolf%20ls would attempt to:

  1. Log you into the current machine. You'll need Remote Login enabled in the Sharing System Preferences pane.
  2. Using the account 'wolf'. You'll probably want to replace this with your own account name.
  3. Upon successful login, execute the ls command. This is just an example, you could put any command in here so long you escape the URI correctly.
  4. Automatically logout when the command terminates. If you don't supply a command, then the ssh session sticks around, as it should.

Update: Stefan Tilkov thinks this is a bad idea.

Thursday, July 17, 2003
12:00 AM