Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am on machine A, hopping onto machine B to finally reach machine C.

A --ssh--> B --ssh--> C

When I ssh-add my private key on A, all works fine and I can hop onto B as many times as I want without supplying any passwords.

When I ssh-add on B, I get this error message:

Could not open a connection to your authentication agent.

The objective is to ssh-add on B too and from there to reach many different C's...

I know how to set up "pass-through" using .ssh/config but that's not what I am trying to do.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You can use the -A option to forward the agent connection to the remote host (ssh commands on B will talk to the agent on A, so you don't need to ssh-add). But note that Agent forwarding may be administratively prohibited on B.

Otherwise, you'll have to start an agent on B:

eval "$(ssh-agent)"
ssh-add ...
share|improve this answer

You need to enable authentication agent connection forwarding (Option "-A").

Example:

hostA$ ssh -A hostB # agent forwarding enabled
hostB$ ssh-add  
hostB$ ssh hostC   # tries now the keys from hostA and the newly added
hostC$

If you do not want to forward a key for security reasons, you could start a new ssh-agent instance by using

hostB$ eval "$(ssh-agent)"
share|improve this answer

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.