Skip to content

Instantly share code, notes, and snippets.

@yuna0x0
Last active April 9, 2025 14:29
Show Gist options
  • Save yuna0x0/1010816cfc09fa418a2e8b1cf37d3ef4 to your computer and use it in GitHub Desktop.
Save yuna0x0/1010816cfc09fa418a2e8b1cf37d3ef4 to your computer and use it in GitHub Desktop.
Harden SSH (Force public key auth and deny root login)
#!/bin/bash
# Force public key authentication
cat > /etc/ssh/sshd_config.d/20-force_publickey_auth.conf <<EOF
PasswordAuthentication no
AuthenticationMethods publickey
EOF
# Deny root login
echo "PermitRootLogin no" > /etc/ssh/sshd_config.d/20-deny_root.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment