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: https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/to-existing-droplet/#manually
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?
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!
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:
- ssh -i ~/.ssh/id_rsa root@DropletIP
You can also use the -v argument in order to get a more verbose output:
- ssh -vvv -i ~/.ssh/id_rsa root@DropletIP
You can also check our tutorial on How to Connect to Droplets with SSH:
https://docs.digitalocean.com/products/droplets/how-to/connect-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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.