0

I am trying to set up ssh config so that if I am sshing using a particular user then use a different key.

By default I want to ssh using my username (abcd) and my identity (~/.ssh/id_rsa)

eg) "ssh example.com" uses user abcd and ~/.ssh/id_rsa ... all good :D

But if I ssh using ssh defg@example.com i want to use the identity file ~/.ssh/id_defg_rsa

eg) "ssh defg@example.com" should use user defg and ~/.ssh/id_defg_rsa

I tried:

User defg
    IdentityFile ~/.ssh/id_defg_rsa

I know I can use an alias but I was wondering if I could just set it up in ssh_config. I know you can condition on the Host, but i am wondering if I can also condition on a user.

da_steve101
  • 283
  • 4
  • 16
  • Perhaps this will help. http://stackoverflow.com/questions/2419566/best-way-to-use-multiple-ssh-private-keys-on-one-client – Avocado Surprise Mar 24 '17 at 03:49
  • Possible duplicate of [Best way to use multiple SSH private keys on one client](http://stackoverflow.com/questions/2419566/best-way-to-use-multiple-ssh-private-keys-on-one-client) – Jakuje Mar 24 '17 at 18:13
  • Not quite what i want :/ thats using different keys for different hosts. I have different keys for different users but sometimes I want to ssh to the same host as user abcd and defg. I don't think ssh_config can do it so i'll think ill just use the "ssh -i" method to specify the key. – da_steve101 Mar 27 '17 at 03:51

0 Answers0