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.

  • 2
    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.
    – quentinxs
    Feb 14, 2012 at 3:39
  • 1
    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! Feb 14, 2012 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, 2012 at 10:41

1 Answer 1


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
  • 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, 2012 at 10:43
  • 1
    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. Feb 15, 2012 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, 2012 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, 2012 at 20:35
  • @chernevik: Instead of writing a new answer, I just edited this one. Feb 16, 2012 at 21:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .