HowTo: Revoke OpenSSH Keys and Disable User Access

https‮/:‬/www.lautturi.com
HowTo: Revoke OpenSSH Keys and Disable User Access

To revoke OpenSSH keys and disable user access, you can use the following steps:

  1. First, locate the user's public and private keys. On most systems, the user's public key is stored in the ~/.ssh/authorized_keys file, and the private key is stored in the ~/.ssh/id_rsa file.

  2. Remove the user's public key from the authorized_keys file by deleting the line that contains the key. This will prevent the user from using their public key to authenticate with the server.

  3. Change the permissions of the user's private key file to prevent the user from accessing it. You can do this with the chmod command, like this:

chmod 600 ~/.ssh/id_rsa

This will set the permissions of the id_rsa file to read-only for the user, which will prevent the user from using their private key to authenticate with the server.

  1. If you want to completely disable the user's access to the server, you can also disable the user's account by setting the user's shell to /usr/sbin/nologin. You can do this with the usermod command, like this:
usermod -s /usr/sbin/nologin username

This will change the user's shell to /usr/sbin/nologin, which is a shell that does not allow the user to log in to the server.

Keep in mind that revoking a user's OpenSSH keys and disabling their access to the server will not delete the user's files or data. If you want to delete the user's files, you will need to do so manually.

It is also a good idea to back up the user's keys and data before revoking their access, in case you need to restore their access at a later time.

Created Time:2017-10-29 22:08:45  Author:lautturi