//Question

How to disable Password Authentication in SSH?

Posted on 19th August, 2024

Evan

Evan

//Answer

To disable password authentication in SSH and enforce the use of key-based authentication, follow these steps:

  1. Edit the SSH Configuration File:

  • Open the SSH configuration file using a text editor:

bash sudo nano /etc/ssh/sshd_config

  1. Disable Password Authentication:

  • Locate the line:

shell #PasswordAuthentication yes

  • Uncomment and change it to:

perl PasswordAuthentication no

  1. Save and Exit:

  • Save the file and exit the editor.

  1. Restart the SSH Service:

  • Restart the SSH service to apply the changes:

    sudo systemctl restart sshd

This will disable password-based authentication, requiring users to authenticate via SSH keys. Make sure your SSH key setup is complete and functioning correctly before making this change, as password authentication will no longer be available.

Comments