Bobcares

Delete SSH Key DigitalOcean | Multiple Methods Revealed

by | Dec 11, 2022

Let’s look into the methods to delete the SSH key in DigitalOcean. Bobcares, as a part of our DigitalOcean Managed Services, offers solutions to every query that comes our way.

Methods to delete SSH key in DigitalOcean

Method 1

If the user is given root access, then it is necessary to change the root password. We can use the below code to lock a user account from SSH access if the user has a separate account:

/usr/bin/passwd developer_user -l

We can also simply remove it using the code:

/usr/sbin/userdel developer_user

Make sure to change ‘developer_user’ = account name.

Method 2

We can use the API methods to delete the SSH key.

delete(key_id) deletes the SSH Key by its id or fingerprint.

delete!(key_id), similar to delete/1 but returns the response body only.

Method 3

We’ve to change the server root password after removing any usernames that the developer may have used from the ssh shell:

userdel

passwd root
Method 4

Find the file /root/.ssh/authorized_keys. Delete any content inside this file. This file stores the SSH key which can be used by anyone having a private ssh key file to login into the server.

Method 5

There are always 2 keys. namely a private and a public key. We can find the keyfiles on the server. We need to open /etc/ssh/sshd_config and find AuthorizedKeysFile .ssh/authorized_keys. Then edit this file to remove the key manually. There may be other users keys also installed.

Open /etc/ssh/ssh_config on the client and check for a different route there. A relative path that varies depending on the user is ~/. The path will change to /root when the ssh command set is run with sudo.

[Looking for a solution to another query? We’re available 24/7.]

Conclusion

To sum up, we provide some simple methods from our Tech team to delete the SSH keys in the DigitalOcean platform.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.