sudo sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config

Category: VPS Management

sudo sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config

Disable SSH password authentication (lockout risk)

WARNING — this command can lock you out: it turns off password logins, so only key-based access works. Apply it only after testing that your key logs in successfully, and never close the current SSH session until you have confirmed reconnection. Also check /etc/ssh/sshd_config.d/*.conf for a PasswordAuthentication line, since those fragments override this file.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.