Skip to content

Instantly share code, notes, and snippets.

@okurka12
Last active August 10, 2025 15:13
Show Gist options
  • Select an option

  • Save okurka12/710527c9fc65c11c687d405851568464 to your computer and use it in GitHub Desktop.

Select an option

Save okurka12/710527c9fc65c11c687d405851568464 to your computer and use it in GitHub Desktop.
Disable SSH password authentication on Debian

Enable key-only SSH authentication

Caution

Only do this AFTER you verified you can authenticate with you SSH key.

Open the config file:

sudo nano /etc/ssh/sshd_config

Uncomment and edit these two lines

PasswordAuthentication no
PubkeyAuthentication yes

Restart SSH service

sudo systemctl restart ssh

Quick check

grep -E "^\s*((PasswordAuthentication)|(PubkeyAuthentication))" /etc/ssh/sshd_config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment