Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
     ___                                     ___  
    |   | (connecting using "hxsr")         |   |
    | A | -----------------------------> P1 | B |
    |___| -----------------------------> P2 |___|

P1 = Private key 1 from user "hxusr" from machine A
P2 = Private key 2 from user "hxusr" from machine A

As you can see I have only "hxusr" user in machine A and machine B, but I want to have to access machine B using 2 different private keys from machine A.

Is this possible?

share|improve this question
    
I rewrote this with some English fixes based on my understanding of the question. If I was wrong in what you are after, please edit it again with a more complete explanation of what you want to accomplish. –  Caleb May 18 '11 at 13:27
    
as an aside, using different key pairs for different hosts is generally recommended (albeit less convenient) as one compromised private key does not equate to many/all compromised remote hosts. –  gravyface May 18 '11 at 13:37
add comment

2 Answers 2

up vote 4 down vote accepted

You can certainly use your choice of more than one key, but I don't think SSH allows for requiring more than one key in a single connection. On the receiving side (your machine B) you specify a list of acceptable keys, and any of them that get provided will do the job.

Besides the config file Ignacio mentions, the ssh command has a -i option that you can use to specify the key file of your choice when authenticating on a case by case basis when you run it.

share|improve this answer
    
Ok but how is the configuration at server side? I mean...will I put the 2 keys from A in in B's authorized_keys? –  jyzuz May 18 '11 at 13:31
    
Yes, you put both of the public keys on separate lines of authorized_keys. –  Caleb May 18 '11 at 13:32
add comment

Yes. Use multiple Host stanzas in ~/.ssh/config, each with a different key. See the ssh_config(5) man page for details.

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.