If I selected the password option when creating my droplet, is it possible to change it to SSH? 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!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Heya,
Yes, as mentioned this is totally doable. On top of what’s already been mentioned I’ll include this article on how to add ssh-keys to existing droplets which you can use to add your key to the droplet.
https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/
Hope that this helps!
Heya,
Yes, you can do that and it’s even a more reliable method to keep your Droplet safe, so it’s a good choice to change it up!
What you’ll need to do is deploy your ssh public key to your Droplet and enable PubkeyAuthentication in your sshd config.
So, let’s begin
Once inside the Droplet, open the file
/root/.ssh/authorized_keys
and paste your public key there. If there isn’t a .ssh directory in your/root
folder, you can create the structure like so:Once that is done, open your sshd config:
Inside you’ll need to find the line
PubkeyAuthentication
and uncomment it or you can just add it as a new lineAlso, if you want to stop PasswordAuthentication, find the line and set it to No
Once that is done, save the file, exit it and restart your SSHD service
That’s it. You can now use your SSH key to enter your Droplet.
Hey there!
Absolutely, you can switch from password authentication to SSH key authentication on your DigitalOcean Droplet. Here’s how you do it:
If you haven’t already, you need to generate an SSH key pair. Open your terminal and use the following command:
Follow the prompts to save the key and add a passphrase if desired.
Your public key will be saved in
~/.ssh/id_rsa.pub
by default. Use this command to copy it:Copy the output to your clipboard.
Log in to your Droplet using the password you set up:
Once logged in, create a
.ssh
directory and anauthorized_keys
file if they don’t exist:Open the SSH configuration file:
Make sure the following lines are set:
To apply the changes, restart the SSH service:
Open a new terminal window and try logging in again with your SSH key:
If you have any questions, feel free to ask. Happy coding!
- Bobby