I want to use different SSH keys for different droplets.
I already have a droplet that uses an SSH key named as the “default”: id_rsa and id_rsa.pub. So I want to use another key for another droplet.
I have tried creating a new SSH key pair by:
ssh-keygen -t rsa
Enter file in which to save the key (/Users/myUser/.ssh/id_rsa): dropletName_rsa
Then I have tried to pass the public key to the server by:
cat ~/.ssh/dropletName_rsa.pub | ssh -p portNumber user@ipadress "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
The key is copied but when I tried to connect with SSH I am prompted with a password request.
If I copy the key with the “default” name: id_rsa.pub. The login without password works. But then I am using the same SSH key pair for two different droplets.
Which solution do you use to improve security?
Thanks,
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!
I encountered the same problem 4 years later. It seems that the only key name that seems to work is id_rsa. If you name you’r key anything else you keep getting the above mentioned errors. Could it be a problem with the way DO checks for keys (only try match keys named a certain way)?
There are a couple options for setting up ssh keys on your droplets.
This tutorial will walk you through manually adding a key to your droplet.
You can also add keys to your account. With this option you can select which key to use when creating your droplet and it will be automatically configured for you when the droplet is created.
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.