Hi, when I create droplets I use the existing functionality provided on the website to automatically add ssh keys to the new server.
I can see my keys are added under /root/.ssh/authorized_keys. That works fine.
However, I have noticed that the /etc/ssh folder has some of it`s own default keys which I never put there.
I cannot delete them because the sshd config defaults to them.
\#HostKey /etc/ssh/ssh_host_rsa_key
\#HostKey /etc/ssh/ssh_host_ecdsa_key
\#HostKey /etc/ssh/ssh_host_ed25519_key
At the same time I cannot change the config to point to /root/.ssh/authorized_keys file as it complains about invalid format.
I could not find any documentation explaining the scenario. https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-existing-droplet/
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!
Accepted Answer
Hi there @philippe15,
You should not really change the HostKey values in sshd_config to point to the /root/.ssh folder, as the /root/.ssh folder contains your client keys.
The keys that you are seeing in /etc/ssh/ssh_host_<rsa/dsa/ecdsa/ed25519>_key are the host keys. Those host keys are generated automatically by OpenSSH when the server first boots.
For more information on how the SSH Host Keys work I recommend checking out the official documentation here:
https://www.ssh.com/ssh/host-key
Hope that this helps. Regards, Bobby
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.