Cloud Servers Help

Remove SSH keys from your server

You can remove a user's SSH key manually while keeping the user itself intact. This is useful in case an SSH private key gets lost or compromised.

Note: If you already removed the user with the -r flag, their SSH keys have already been deleted and you do not need to complete these steps.

Difficulty: 1
Time: 5 minutes

Remove the SSH key

  1. Log in to your server via SSH.
  2. Switch to the root user:
    sudo su -
  3. Find that user's home directory:
    echo ~user's username

    You will see your user's home directory. This is usually /home/user's username.
  4. Using this path, remove the .ssh folder from that user:
    rm -rf /home/user's username/.ssh

You have removed that user's SSH key.

Create a password

After you have removed the key, you must give this user a password or they will be unable to log in.

  1. Make sure you are still logged in as root.
  2. Use the passwd command to change your user's password:
    passwd user's username
  3. Enter a new password, and then confirm it.

Your user's password is now updated.

Next step

Add an SSH Key to an existing server

Was This Article Helpful?
Thank You For Your Feedback
Glad we helped! Anything more we can do for you?
Sorry about that. How can we be more helpful?