Last active
April 9, 2025 14:29
-
-
Save yuna0x0/1010816cfc09fa418a2e8b1cf37d3ef4 to your computer and use it in GitHub Desktop.
Harden SSH (Force public key auth and deny root login)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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