Skip to content

Instantly share code, notes, and snippets.

@midlan
Last active February 14, 2025 14:07
Show Gist options
  • Save midlan/fe2628706685b44e04af1b79b66a32d8 to your computer and use it in GitHub Desktop.
Save midlan/fe2628706685b44e04af1b79b66a32d8 to your computer and use it in GitHub Desktop.
PermitRootLogin no
UsePAM no
PasswordAuthentication no
ChallengeResponseAuthentication no

Install

Place into /etc/ssh/sshd_config.d/10-noroot-nopass.conf

Create sudo user

Exec under root:

NEWUSER='changeme'
adduser "$NEWUSER"
echo "$NEWUSER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEWUSER

#disable password login
usermod -p '*' "$NEWUSER"

#root dsable password login and ssh login (even with valid ssh key)
usermod -p '!*' root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment