Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create quick-access ssh shortcuts Network
To quickly open an ssh connection from nearly anywhere on your Mac, do the following:
  1. Open TextEdit and type in your connection string in the form of: ssh://user@host.com
  2. Select the whole line and drag and drop it on the Desktop. The result will be a *.inetloc file.
  3. Move the file to any folder you like. I made one named ~/connections that holds all of my *.inetloc files. You can rename this file to whatever you like, and even change its icon.
  4. Now you can drag and drop the *.inetloc file to the Dock, the Finder's Sidebar or Tool bar, or to anywhere else. (It can even be selected with Spotlight)
  5. If you use LaunchBar, open the Launchbar Configuration screen (Command-Y) and add another rule for your connections folder. Now your SSH connections can be opened with LaunchBar. I believe you can do similar with LaunchBar and Quicksilver, enabling quick launching of your SSH shortcuts.
A more lengthy explanation is available in my blog, containing some screenshots as well.

[robg adds: This doesn't seem to work for a few of my sites, which use the domain in the username -- i.e. my command would look like this: ssh://robg@mydomain.com@www.mydomain.com. The dual @ signs seem to confuse the ssh command, resulting in an incorrect command format: ssh mydomain.com@www.mydomain.com. For my domains that don't use this format, however, this trick works quite well.]
    •    
  • Currently 3.40 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[43,209 views]  

Create quick-access ssh shortcuts | 21 comments | Create New Account
Click here to return to the 'Create quick-access ssh shortcuts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create quick-access ssh shortcuts
Authored by: aebi on Aug 11, '06 08:23:28AM

You can even set the port of the server:
ssh://philippe@test.com:2222



[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: Melle on Aug 11, '06 08:25:13AM
Rob, maybe you could try url-encoding the @-sign in your username, like so:
ssh://robg%40mydomain.com@www.mydomain.com
unable to try it from here, but pretty sure that should work...

[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: captainulf on Aug 15, '06 03:28:18AM

That certainly does the trick for me. Excellent.



[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: jeremyp on Aug 11, '06 09:08:52AM
Rob, you can create an entry for your host in ~/.ssh/config with a user specified and then use this trick e.g. .ssh/config could contain

host typhon-ext
User foo@bar
hostname tuscan.foobar.co.uk
and then the inet-loc would contain ssh://typhon-ext This will log you in as user foo@bar.

[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: pepi on Aug 11, '06 11:19:17AM

Exactly what I do. Have a nicely configured

~/.ssh/config
with all the setting I need, including X11 forwarding, port forwarding/taunneling/reflection, usernames, compression, etc.

I can of course call them from LaunchBar which can issue terminal commands like ssh nickname. I am sure you can do this with QuickSilver as well, possibly even Butler, both of which I do not use, hence I don't know them so well.

Pepi

[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: mkmccarty on Aug 11, '06 12:05:30PM

When using the inet-loc file by clicking on it from the finder or by entering the ssh://hostalias directly from Safari, the X11 forwarding settings contained with the .ssh/config file aren't being observed.

From any terminal a "ssh hostalias" works properly.



[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: baba on Aug 11, '06 09:47:53AM
I prefer to do this by saving terminal sessions to a term file. Simply set up your terminal window how you like it for a given remote host (background color, character set, window size and location, etc.) then save. The save dialog will give you the option to "Execute this command". Check that and add your ssh line:
e.g.,
ssh -Y username@some.server.edu
You can move the .term file to a central folder and even add aliases to have easy access from the command line:
e.g., in ~/.bash_profile (or /etc/bashrc):
alias some='open /path/to/folder/some.term'
In the terminal the command 'some' will open a new customized terminal window and run your saved ssh command.

[ Reply to This | # ]
.term files not workin' on Intel iMac
Authored by: texlogic on Aug 11, '06 08:13:05PM
I prefer to do this by saving terminal sessions to a term file.
Yeah, me too, I have a bunch of them on my old Powerbook. But, strangely, .term files don't work for me on my Intel iMac. More accurately, a .term file will do as it ought only if I open it when Terminal.app isn't running. Once Terminal.app has been started, if I call a .term file via Launchbar or try to open one from the command line with "open foo.term", nothin' happens (even if no Terminal windows are up). .term files *do* work if I open them via Cmd-O from inside Terminal.app, but that's kludgy way to call them. I should note that the present Hint does work on my iMac, i.e., I can open an .inetloc file that points to a remote machine and an ssh session to that machine does faithfully open in a Terminal window. But that gives you far less flexibility, as all remote sessions so called look the same -- same font, same colors, same titlebar (ssh://remotebox.com), etc. When you're regularly ssh'd in to three or four machines, it's nice to distinguish them via different colors and such. (I reckon an Apple maven could write an Applescript to add colors and the like, but I'm just an old unix jockey and wouldn't know where to begin -- and I'd just rather that .term files worked! :-)

Anybody have any idea what's going on here with my .term files?

Texlogic

[ Reply to This | # ]

Create quick-access ssh shortcuts
Authored by: pknull on Aug 11, '06 11:44:28AM

I use term files personally, and then I have a radial menu linked to a hot key in Quicksilver.

So I hit f4, and click the term file I want, and off I go.



[ Reply to This | # ]
correction
Authored by: Whosawhatsis on Aug 11, '06 02:06:03PM
"Now your SSH connections can be opened with LaunchBar. I believe you can do similar with LaunchBar and Quicksilver..."

I believe that was meant to be:

"Now your SSH connections can be opened with LaunchBar. I believe you can do similar with Butler and Quicksilver..."

---
I was offered a penny for my thoughts, so I gave my two cents... I got ripped off.

[ Reply to This | # ]

Create quick-access ssh shortcuts
Authored by: vocaro on Aug 11, '06 03:19:46PM
In step 2, when it says, "Select the whole line," it means "Select the whole line, except for the newline." I couldn't get this hint to work unless I selected only the text of the line.

[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: gk5885 on Aug 11, '06 04:54:17PM

since these are really just urls, an easier way to do this is to just type the shortcut into the address field in safari (don't hit return) and drag the little globe icon to wherever you want the shortcut.



[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: baba on Aug 11, '06 09:25:05PM
Wow, this sounds like a substantial bug for me. I was just about to order a Mac Pro, but I've got to have working term files. Have you reported this to Apple?
I guess this intel migration is ongoing, so I'll have to bide my time.

[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: dogzilla on Aug 11, '06 09:46:28PM

With the solutions above, I believe you will still have to enter a password. I get tired of entering passwords all the time when I ssh into another machine, since I have to do it *all* the time on a bunch of different machines. Instead, I've created the following process:

1) create a new file in ~/bin (create this directory if it doesn't exist)
2) modify the following and enter it into the file:
<code>
#!/usr/bin/expect --
spawn ssh some.server.name
expect "Password:"
send "somepassword\r"
interact
</code>
Obviously, "some.server.name", "Password:", and "somepassword" should be changed to reflect the specific instance of your setup. (The trailing "\r" should remain). You can even use this to su after login by including additional expect / send blocks.
3) give the file some easily remembered name (avoid spaces)
4) change the permissions for the file so it's executable: (from the command line, you would do this by typing "chmod 700 ~/bin/somefile")
5) close and open your terminal or type "rehash" at the command line

You should now be able to simply type the name of the file and be connected to the server. You can also duplicate & rename the file and edit it for other server connections. This method has worked quite well for me - I type a single word and I'm automatically connected to the server.



[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: statistics on Aug 12, '06 12:27:10AM
I would think that SSHKeychain would be a more secure way to achieve this convenience.

[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: rpaul on Aug 12, '06 06:56:59AM

You can even embed this into an anchor on a web page/sidebar menu - works well with Safari:

<a href="ssh://user@host.com">user@host.com</a>

Very cool!



[ Reply to This | # ]
Do you work for the gov.t, or a bank?
Authored by: klktrk on Aug 14, '06 09:27:55AM

The author of this comment appears to work for the govt or a bank, 'cause I can't imagine a private person being this irresponsible with data. Once someone gets into your home folder (not at all difficult) they can have a field day with any machine you administer via SSH. Typing SSH passwords into text files in plain text is beyond me. I simply cannot fathom the mental process which would allow someone to do that. You might as well just lie down in the middle of a freeway.



[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: oliverlangan on Aug 21, '06 05:26:37PM
I also had the same problem of having to enter passwords all the time, but I think a cleaner (and built-into-ssh) way than putting actual passwords into text files is to set up an ssh identity (using ssh-keygen), and then putting the public key for that identity on all the machines you want to log into. It takes some initial setup, but it is much more secure and even works when the account password to the machine changes (it is using the key to negotiate the encryption, not the password).

The key will also be used automatically for SFTP (including in programs like Interarchy, Transmit, etc) and can be used to log into multiple accounts with different logins on the target machines.

There are some good how-to documents on setting this up, e.g.,
http://www.zettai.net/Support/Howto/sshKeyHowto


[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: 10drill on Aug 12, '06 08:45:20PM

The method described in this hint works for making smb:// .inetloc files too...



[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: oliverlangan on Aug 21, '06 04:06:58PM

I have done this for a while now: initially I stored the ssh (and sftp) URLs in Safari so that they synced between my machines, but I hated switching to safari to open the Terminal or Interarchy. Now I do as the hint recommends, keeping them in a folder: but that folder is on my iDisk so that the URLs are still synchronized.



[ Reply to This | # ]
Create quick-access ssh shortcuts
Authored by: mdame on Jun 27, '07 06:32:32PM

I have the same problem: X11 forwarding isn't working with either .term files or .inetloc files. Anyone have this worked out?



[ Reply to This | # ]