How to disable ssh password login on Linux to increase security

To disable password authentication for SSH on Linux, follow these steps:

  1. Open the SSH configuration file:
    sudo nano /etc/ssh/sshd_config
  2. Find the line that says:
    #PasswordAuthentication yes
  3. Uncomment the line by removing the # character and change yes to no. It should look like this:
    PasswordAuthentication no
  4. Save the file and exit the editor.
  5. Restart the SSH daemon to apply the changes:
    sudo systemctl restart ssh

Now, users will only be able to log in using a private key, which is much more secure than using a password.

Note: Before disabling password authentication, make sure you have a way to log into the server using a private key. If you lock yourself out, you’ll need to have physical access to the machine or another means of access, such as a rescue mode, to regain access.

(https://bluffsrehab.com/)

Leave a Comment