Secure SSH by Disabling Password Login
If your SSH port is exposed to the internet and your account password is compromised, an attacker could use it to log in to your server. One way to reduce this risk is to disable password login and require an authorized SSH key instead. Only clients with access to the matching private key can authenticate, so a stolen account password alone is not enough.
Here is how to configure it, check the settings, and test a new connection without locking yourself out.
The server commands below are for Debian. On other systems, the configuration paths, service names, or service-management commands may differ.
