___ ___
| | (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?
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.Yes. Use multiple
Host
stanzas in~/.ssh/config
, each with a different key. See thessh_config(5)
man page for details.