2

I have a CentOS-running server and I want to add ssh authentication for my laptop and desktop-computers. Both PCs are running Ubuntu. I managed to get it work with one computer. I added id_rsa.pub to my /home/$USER/.ssh/autheticated_keys-file. Then I disabled password protection so I can log in only if I have that ssh key on my computer.

I tried to add that second id_rsa.pub-key to that authenticated_keys-file on my server, but it didn't work. Like this:

cat id_rsa.pub >> /home/$USER/.ssh/authenticated_keys

Is this the right way to do this? Or how to save two different public ssh keys on a server? (...and on a single user account)

3 Answers 3

7

Assuming you mean authorized_keys then yes, that should work. Check that the file has exactly two lines and that there aren't any extra spaces or anything in the key line for the second key. Also check that you have added the correct lines for each desired key.

1
  • Yes, I meant authorized_keys of course. That worked. I had pasted wrong file to authorized_keys-file so it didn't work in the first place. Thank you!
    – hemppa
    Jul 1, 2013 at 17:46
1

You could use ssh-copy-id <remoteHost> from your laptop and/or desktop. Saves you the extra step of copying your public key across to cat it into the authorized-keys file. This is my personal preference, but directly inserting the public key works too :)

0

In authorized_keys file you have below format required to work two or more keys

ssh-rsa  your_public_key  PCname
ssh-rsa  your_second_public_key PCname

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .