Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently logging in to a remote server by opening terminal, starting ssh-agent, adding a key, launching xterm and then connecting via ssh.

What tools should I be using for this? I've looked at keychain, but the docs don't explain how to use it for ssh.

share|improve this question
Are you logging into a Linux server? If so, just opening up Terminal and running "ssh user@my.server.address -X" will automatically launch xterm for you; no need for any extra steps. – qsheets Feb 14 '12 at 3:39
Can you provide some additional information like what tasks you are performing remotely on this server? Is this a company server you manage in the office (inside it's LAN) and outside of the office? Thanks! – Nick Arvelo Feb 14 '12 at 18:50
Mostly I am starting and stopping servers, pulling code from git, editing that code for development. Sysadmin and development. – chernevik Feb 15 '12 at 10:41
up vote 2 down vote accepted

It should Just Work. In more detail: First, don't run ssh-agent yourself, since launchd will run it for you on demand. Make sure your private ssh key is in ~/.ssh/ with appropriate permissions, i.e., not readable by anybody but yourself:

; ls -l .ssh/id_dsa
-rw-------  1 user  13799  736 Oct 12  2001 .ssh/id_dsa

Now run ssh remote-hostname. A dialog should pop up to let you unlock the key. The dialog has a check button for storing the pass phrase in your keychain. Check it, and hit OK. (You need to do this with /usr/bin/ssh, I think, and not any ssh that you might have from macports or fink.) If you don't get the dialog, it could be that ssh needs to be told about the name and location of your private key. If so, specify it using the -i flag, as in

ssh -i .ssh/id_dsa remote-hostname
share|improve this answer
It doesn't. When I try to ssh to the server, I can "Permission denied (publickey)" with no request for a passphrase. – chernevik Feb 15 '12 at 10:43
Well, that's odd. I've had my current setup for so long, I had forgotten what I did to set it up. So before posting my answer, I actually tried it with a test user, and it worked just like I said. What happens if you run ssh -v remote-hostname? When I do that, I can see from the debug output that it's going to try my public just as the pass phrase dialog pops up. If you see no mention of public keys in the debug output, I would suggest your ssh or sshd configs. – Harald Hanche-Olsen Feb 15 '12 at 20:11
Got it. The trick is to connect without setting up the ssh agent and specifying the key file with the -i option to ssh. The passphrase dialog pops up with the promised option to save to keychain. – chernevik Feb 15 '12 at 20:21
One of us should write this up as the answer -- if you do it, you'll get the upvote you've earned – chernevik Feb 15 '12 at 20:35
@chernevik: Instead of writing a new answer, I just edited this one. – Harald Hanche-Olsen Feb 16 '12 at 21:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.