Add SSH key after creating a droplet
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.×
A question can only have one accepted answer. Are you sure you want to replace the current answer with this one?
You previously marked this answer as accepted. Are you sure you want to unaccept it?
cat ~/.ssh/id_rsa.pub | ssh firstname.lastname@example.org "cat >> ~/.ssh/authorized_keys"
Exactly! I had to add an SSH key to an existing droplet but couldn’t log in via SSH because of “permission denied (publickey)” so all these instructions are not working if you disabled password login. I lost a lot of time trying to get access to my droplet from a new computer. The only solution was to get my old computer and log in from there with the old SSH key. The Digital Ocean console is completely non-functional. It just doesn’t work. If I paste in my SSH key it gets altered, upper-case letters become lower-case letters, the string is cut off in the middle etc. and it’s extremely slow and non-responsive. All in all a very frustrating experience!
Here’s the tutorial:
Also I cannot se any droplet resize option available, any ideas why is that?It could be that the physical server that your droplet is on does not have enough available space to resize your droplet -- can you post a screenshot of the resize page?
For anyone finding this via Google that found this answer: logging into your droplets via SSH on a Windows machine where you might be using a specialized client to generate your keys, the command asb uses in this comment thread doesn’t work, and there really aren’t any answers to tell you why.
Here’s an explanation. For a quick command-line copy and paste answer, scroll to the bottom of this comment. Breaking down the command:
On a *NIX machine, this would output your local public SSH key.
The pipe character is standard Shell-speak for “piping” data into the stdin (input console) of a program or file handle. An easy way to remember it is the output of the command on the left will be received as input for the command on the right.
ssh email@example.com "cat >> ~/.ssh/authorized_keys"
This is standard use of the SSH command, except the part in quotes actually encloses a command to send to the server you’re SSHing into.
What this adds up to mean is “output my local public key into the authorized_keys file on the server I’m SSHing into”. Which, on Windows, unless you use a platform like Cygwin for all of your SSH, means it wouldn’t work, because Windows isn’t a *NIX-style platform.
Solution for Windows users using native SSH clients: Paste the following into a root shell on your droplet:
echo "YOUR_SSH_PUBKEY_GOES_HERE" >> ~/.ssh/authorized_keys
Your SSH key should now be authorized on the droplet.