By alessandroc
How do I enter my public key? When I access the console from you and open the authorized_keys to place my key it breaks the characters …
I can not access my terminal because I need my key in authorized_keys
can you help me insert my public key into authorized_keys?
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!
Hi there,
the easiest way to copy your public key to your droplet is with SCP. On a typical Linux/macOS machine, you’d do the following:
scp ~/.ssh/id_rsa.pub username@<droplet_IP>:~/.ssh/authorized_keys
where ~/.ssh/id_rsa.pub is the location & name of your public key on your local machine. Also, be sure to replace username with the actual username on your droplet and enter the correct IP. Also, note the colon character between the droplet’s IP and the path of the authorized_keys file on your droplet.
It might also be a good idea to ensure the .ssh directory on your droplet has proper permissions. On your droplet, you might want to run this first:
sudo chmod -R 700 ~/.ssh/
I see. Since you’ve claimed above that the console breaks the characters upon pasting, it’s likely the public key you have pasted that way is corrupted in some way. The fastest way to recover is to start from scratch. If you’re still able to log into your droplet with a password, do so, otherwise log in through the console and remove the .ssh directory entirely:
sudo rm -rf ~/.ssh/
Afterwards, recreate the directory with the proper permissions in place:
mkdir -p ~/.ssh && sudo chmod -R 700 ~/.ssh/
and then follow the instructions I posted in my previous post on how to properly copy your public key file with scp.
Hope this helps!
I get the following error message when I try to run my command from my terminal: Permission denied (publickey). lost connection
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.