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.

Let's say there are two keys A and B, both of which are valid for user@host public key authentication. Since authorized_keys is configured for different behaviour depending on the key, ~/.ssh/config on the client uses something like

Host A.host
    HostName host
    User user
    IdentityFile ~/.ssh/A
Host B.host
    HostName host
    User user
    IdentityFile ~/.ssh/B

That works fine. However, the moment I use ssh-agent and add both keys A and B (e.g. in order to enter their passphrases at login instead of when I call the respective ssh A.host or ssh B.host), the connection will always use the same id for both virtual hosts. Is there any way to specify which stored key ssh should use from ssh-agent without having to remove the other key?

share|improve this question
1  
See serverfault.com/questions/401737/… –  jasonwryan Oct 17 '12 at 16:55
    
Thank you @jasonwryan, this leads me to believe I have to add IdentitiesOnly yes. That's also the answer to another question which weirdly ended up on SU... I'll try this tomorrow –  Tobias Kienzler Oct 17 '12 at 17:59

1 Answer 1

up vote 3 down vote accepted

As answered elsewhere, the trick is adding the option IdentitiesOnly yes which makes sure that only the configured keys will be used even if others are available from the 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.