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 love ssh -A, which allows me to use my local ssh key when establishing a connection from a remote server. For example, I ssh -A and then from there I can ssh (or use git) and it uses my ssh key from the original machine, which in this case should be my mac. Although this has always worked for me on Debian/Ubuntu, it doesn't work on my new mac (Lion).

What am I missing here? How do I configure ssh to work correctly with -A? Do I need an ssh that is not the standard MacOS one?

share|improve this question
up vote 17 down vote accepted

Actually, the very simple answer is that you have to run


and then it all works.

share|improve this answer

As of OS X 10.8 you need to do this once:

sudo touch /var/db/useLS

And add this as part of your ~/.bash_profile:

if [ -f ~/.ssh/id_rsa ]; then
    ssh-add -K ~/.ssh/id_rsa 2>/dev/null

Note: this recipe is parto of my bedouin scripts.

share|improve this answer
Hm, just tried this out; the agent does then start, but you still have to ssh-add to get anything to work. So ssh-add alone is still the answer, as far as I understand. I guess I should add it to my .bash_profile. – rfay Jan 19 '13 at 14:53
lol, what if my private key needs a passphrase? – Jeffrey04 Oct 23 '15 at 3:05

The concept behind ssh -A are ssh agents. They run in the background and through the use of environment variables the agent can be located and automatically used for authentication when logging in to other machines using ssh. Have a look at the manpage of ssh-agent for more details.

With Mac OS X, the ssh-agent should be started on demand.

For more information see:

share|improve this answer

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.