SSH Setup for a Newbie

Posted April 30, 2014 3.6k views
The workflow for setting up an SSH key is not totally clear for a newbie. I followed and created my key pair, but adding the public key to Digital Ocean is a little confusing. I am not able to copy the contents of the public key from the online console (copy/paste not available), and I am not sure what adding the key does. Can anyone explain this step-by-step without a lot of code. I looked at this and it also confused me: Note that I am trying to add SSH to an existing droplet. I have already created the key pair.

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.

Submit an Answer
2 answers
You should be a able to simply add your public key you to the authorized_keys file in your home directory /home/username/.ssh/authorized_keys file on your cloud server. You can either scp the file up to your cloud and add it it /home/username/.ssh/authorized_keys or even easier just copy the text of it an paste it into your /home/username/.ssh/authorized_keys (using vi or nano editor) on your cloud server. The main thing you have to remember is that your the .ssh folder and authorized_keys folder on the cloud server cannot be readable by anyone but your user or it will not work. You should set the permissions for /home/username/.ssh and authorized_keys to 700. Once this is done you should be able to ssh in without a password. If it doesn't work try ssh username@host -vvv to get more information on the exact error and post here for more help.
Adding a SSH key allows you to access the droplet without having to use a password. It is also more secure as you can then disable password authentication all together. That way only the key can be used to access it, and someone won't be able to use brute force attacks to try to login to your server.

It sounds like you are generating the key on the droplet itself. What you actually need to do is create the key on your local computer, not the remote server. You then copy the public key to the server while the private key stays on you local computer.

What OS are you using locally? If you're using Windows, you might want to look into using PuTTY: