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?
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!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Click below to sign up and get $100 of credit to try our products over 60 days!