Take the 2-minute tour ×
     ___                                     ___  
    |   | (connecting using "hxsr")         |   |

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

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? –  jyz 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

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

Your Answer


