Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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 host1.example.com and then from there I can ssh host2.example.com (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
add comment

3 Answers 3

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
fi

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
add comment
up vote 8 down vote accepted

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

ssh-add

and then it all works.

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.