If this is a duplicate, I'm sorry.
I have searched my case but I couldn't find the right scenario that resembles my situation, although I thought that this situation must have come up before for someone.
Here we go:
I have a user on my remote linux server, ServerUser.
I have a user on my home PC, HomeUser.
I have a user on my work laptop, WorkUser.
I want to connect with HomeUser and WorkUser to the ServerUser with individual ssh keys, instead of generating one and copying it over to the other user.
HomeUser --- ABC-SSH-KEY ---> ServerUser
WorkUser --- XYZ-SSH-KEY ---> ServerUser
This seems like a very common situation for me but oddly enough I was not able to find information about that.
How do I set this up?
Comment to solution:
I first had re-enable password login on the server but then the marked solution worked fine.
So to get the new key on my work laptop working, my steps in total were:
- generate a key on the work laptop, for example as
ssh-keygen -f ~/.ssh/publicKeyOnWorkLaptop
(-f option to specify an output path and a name)
- log in on the server from my home PC, with the user that already had a working ssh-key
- re-enable ssh password login on the server in
/etc/ssh/sshd_config
with PasswordAuthentication yes
- back on the work laptop run
ssh-copy-id -i ~/.ssh/publicKeyOnWorkLaptop.pub ServerUser@Server
, give the password when prompted
- roll back ssh password login to
PasswordAuthentication no
from step 3
- verify that the public key login works from the work laptop with
ssh -i ~/.ssh/publicKeyOnWorkLaptop ServerUser@Server