DigitalOcean Droplet SSH keys: what deleting a key does not undo
DigitalOcean copies your SSH keys onto a Droplet once, when it is created, and never touches them again. Deleting a key from your team does not remove it from any Droplet, so rotating or revoking one means editing authorized_keys on each machine yourself.
SSH keys feel like a solved problem. You add one when you create a Droplet, you log in without a password, and nothing more is said. The trouble starts a year later, when someone leaves, a laptop is replaced, or you want to know which keys can still get into production.
Where keys live, and when they are used
DigitalOcean keeps public keys at the team level. The team SSH keys page has you switch to the team, open Settings, then the Security tab, and add a key under SSH Keys. On the command line the documented forms are:
doctl compute ssh-key import laptop-2026 --public-key-file ~/.ssh/id_ed25519.pub
doctl compute ssh-key list --format ID,Name,FingerPrint
doctl compute ssh-key delete <key-id-or-fingerprint>
The doctl ssh-key reference lists the columns ID, Name and FingerPrint for the output, and an update command that renames a key. Note that the doctl and API pages still say "account" where the control panel says "team". SSH keys are also a different credential from API tokens, which the API tokens article covers.
A key is only used when a Droplet is created. The API reference says keys you select are embedded in the Droplet's root account at creation, and the Droplet API wants the keys on your team before you can use them. That is all DigitalOcean does with them. After that, the key on the Droplet is your problem.
What deleting a key from the team does not do
Two documented sentences matter more than anything else here. The doctl import page says importing a key will not add it to any Droplets. The delete page, and the team page, say deleting a key does not delete it from any Droplet's SSH configuration. In DigitalOcean's words, deleting an SSH key from a team only removes the ability to create new Droplets with that key already added.
So a key you delete today still logs in to every Droplet created with it yesterday. The team limits page makes the same point about people: removing someone from a team does not revoke their access to Droplets through SSH keys, because DigitalOcean does not manage the contents of Droplets after creation. If you have ever offboarded someone by removing them from the team and stopped there, check the Droplets.
Passwords after you use a key
When you create a Droplet with an SSH key, password authentication is disabled by default, and trying to log in with a password gives a permission denied error for the public key. That is good, and worth knowing for a different reason: it makes the key the only way in, so the key's lifecycle is the access lifecycle.
DigitalOcean's pages disagree about one related detail. The doctl create reference says that if you give no SSH key, a temporary password is emailed to the account's address, while a support page says that after creation the password is not sent by email. Do not rely on either. Create Droplets with keys, and keep password login off.
What the recommended setup actually does
The recommended Droplet setup aims for key authentication for a sudo user that is not root, no password access to root, and a Cloud Firewall limited to SSH on port 22. Its cloud-init script creates the user, copies root's authorized_keys to it, and sets PermitRootLogin prohibit-password.
Read that last setting precisely. It governs the root user only. The page describes the script as disabling password-based login, but the lost-key page is the one that recommends PasswordAuthentication no for everyone. If you copy the script, add that line and check it took effect. The firewall half is covered in the Cloud Firewall article.
Adding a key to a running Droplet
DigitalOcean is direct: for security reasons, you cannot add or modify SSH keys on a Droplet using the control panel after you create it. The add keys to an existing Droplet page gives three methods, and recommends ssh-copy-id. The second is a one-liner that appends your public key over an existing session:
cat ~/.ssh/id_ed25519.pub | ssh user@your-droplet-ip "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
The third is editing ~/.ssh/authorized_keys by hand, with permissions 700 on the directory and 600 on the file. If you have lost access altogether, the documented recovery path is the Recovery Console to reset the root password, then add the key from the console or briefly enable password authentication.
Generating a modern key takes one line, and DigitalOcean's own examples use ed25519:
ssh-keygen -t ed25519 -C "[email protected]"
On key types, the documentation is thin and slightly inconsistent. We found no list of supported types and no stated minimum. One page says a 2048-bit RSA key pair is fine for most uses, while the walkthrough output and default file names are ed25519. The one firm negative is that on servers running OpenSSH 7 or newer, older DSA keys are not supported for authentication and are considered weak.
Removing or rotating a key, which DigitalOcean does not document
Here is the honest gap. The documentation covers adding a key to an existing Droplet and does not give a removal or rotation procedure. The workaround is the one you would use on any Linux host:
- Add the new key to
authorized_keyson each Droplet, and confirm you can log in with it from a second terminal. - Delete the old key's line from
authorized_keys. - Delete the old key from the team, so new Droplets stop receiving it.
Keep that order. Removing the old line before you have confirmed the new key works is the classic way to lock yourself out of a Droplet, and recovering means the Recovery Console.
Because nothing in DigitalOcean lists which keys sit on which Droplet, build that list yourself. First the keys your team can embed, then what each Droplet actually trusts:
doctl compute ssh-key list --format Name,FingerPrint
for ip in $(doctl compute droplet list --format PublicIPv4 --no-header); do
echo "== $ip"
ssh -o BatchMode=yes root@"$ip" 'ssh-keygen -lf ~/.ssh/authorized_keys'
done
Replace root with your sudo user if you followed the recommended setup, since the key is then in that user's file too.
Each line that ssh-keygen -lf prints is a bit length, a fingerprint, the comment on the key and its type. Match those against your team keys and against your people. We ran the key-generation and fingerprint commands locally, but not the loop against a live account, and the fingerprint format DigitalOcean shows should be checked against what you compare it with: OpenSSH prints SHA256 by default and can print MD5 with -E md5. A key whose comment is a laptop you no longer own is a finding.
Other ways in that do not use your keys
The Droplet Console is a second path to a shell. DigitalOcean's console page says it offers one-click SSH access without a password or manual key configuration, and that the Droplet agent behind it needs outbound TCP access to 169.254.169.254 to retrieve SSH keys. The agent is installed by default on Droplets created after August 2021, and the documentation gives no key hygiene guidance for it. The practical reading is that anyone with control panel access to a Droplet has a way in that your authorized_keys file does not describe, so team roles matter as much as keys. The team roles article covers them.
One last constraint. A Private Droplet, which has no public IP address, has no console either, so you reach it through a bastion host. The VPC article explains how those work.
FAQ
Does deleting an SSH key in DigitalOcean remove it from my Droplets?
No. DigitalOcean states that deleting a key from the team only stops new Droplets from being created with it. It does not remove the key from any Droplet's SSH configuration.
Can I add an SSH key to an existing Droplet from the control panel?
No. DigitalOcean says you cannot add or modify SSH keys on a Droplet through the control panel after creation. Use ssh-copy-id or edit authorized_keys, or use the Recovery Console if you are locked out.
Is password login disabled on a Droplet created with an SSH key?
Yes by default, according to DigitalOcean. The recommended setup script only disables root password login, so set PasswordAuthentication no if you want it off for every user.
How do I see which keys a Droplet trusts?
DigitalOcean does not list this. Log in and read the authorized_keys file, for example with ssh-keygen -lf, and compare the fingerprints against your team keys.
Secorvia reads DigitalOcean with a read-scope token and does not log in to your Droplets. The DigitalOcean integration page and the DigitalOcean page say what it covers.