Adding additional SSH key to existing Droplet

I have a droplet with no-password ssh access. I would like to provide access to my colleague.

I had him generate a key-pair on his linux machine, and got his public key. Then, I added his key to the ~/.ssh/authorized_keys file along with my key, following the tutorial here:

I did set the permissions afterwards as instructed.

I’m still able to ssh in, but he cannot: Error Permission denied (publickey)

I tried service sshd restart, but to no effect.

Similarly, I tried to set myself up from a different machine, but again I’m getting the same permission denied error.

I read some other tutorials that suggested to set a password authentication, but that’s not what I want to do. Need ssh login.

Any tips?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello, @geochanto

You can make sure that the correct ssh-key is used for the connection. If you’re using ssh-client (terminal) you can use ssh -i to specify the exact ssh-key you want to use for the connection. An example is:

  1. ssh -i ~/.ssh/id_rsa root@DropletIP

You can also use the -v argument in order to get a more verbose output:

  1. ssh -vvv -i ~/.ssh/id_rsa root@DropletIP

You can also check our tutorial on How to Connect to Droplets with SSH:

You can also make sure that the file/folder permissions are okay

  • Your home directory ~, your ~/.ssh directory and the ~/.ssh/authorized_keys file on the remote machine must be writable only by you: rwx------ and rwxr-xr-x are fine, but rwxrwx--- is no good, even if you are the only user in your group (if you prefer numeric modes: 700 or 755, not 775).

  • If ~/.ssh or authorized_keys is a symbolic link, the canonical path (with symbolic links expanded) is checked.

  • Your ~/.ssh/authorized_keys file (on the remote machine) must be readable (at least 400), but you’ll need it to be also writable (600) if you will add any more keys to it.

  • Your private key file (on the local machine) must be readable and writable only by you: rw——- , i.e. 600.

Regards, Alex