Ssh – Is it possible to use one SSH key per account for each account on a given remote server

key-authenticationssh

Suppose I have a number of accounts on a server called SERVER. Let's call them ACCOUNT1, ACCOUNT2 and ACCOUNT3.

Suppose I don't want to have to type in the password for the account each time I ssh into one of those accounts from my local computer, DESKTOP.

Obviously, I could use a single ssh key pair to allow myself passwordless login to all three accounts, but is it possible to use a different ssh key pair for each account?

Best Answer

You can manage these identities with ~/.ssh/config. For example:

Host acc1-server
     User ACCOUNT1
     Hostname SERVER
     IdentityFile ~/.ssh/id-ACC1-SRV

Host acc2-server
     User ACCOUNT2
     Hostname SERVER
     IdentityFile ~/.ssh/id-ACC2-SRV

Afterwards just type ssh acc1-server to connect to SERVER as ACCOUNT1 with key ~/.ssh/id_rsa-ACC1-SRV, or ssh acc2-server to connect to SERVER as ACCOUNT2 with key ~/.ssh/id_rsa-ACC2-SRV ;-)

Related Question