How can I modify my sshd_config
so that it blocks access to all users except the root user?
I've had a look and I tried
AllowUsers root
DenyUsers *
But that doesn't do anything
How can I modify my sshd_config
so that it blocks access to all users except the root user?
I've had a look and I tried
AllowUsers root
DenyUsers *
But that doesn't do anything
I tried this myself, adding only the AllowUsers root
line, which worked without a hitch. Probably an obvious question, but since you didn't mention it explicitly: did you restart the sshd
service after making the modification?
If you're using Linux, you can use the pam_succeed_if.so PAM module (if your distro has it). Other OSes may or may not have it so YMMV.
in /etc/pam.d/sshd:
account sufficient pam_succeed_if.so login = <username>
You can also allow specific groups, or numerical uids/gids, etc.
See http://linux.die.net/man/8/pam_succeed_if for more information on this PAM Module.
This method doesn't involve sshd_config, but the effect is the same. I lockout all users except root when I need to do maintenance on my Linux hosts. Just remove the file when you're done.
echo "System maintenance in progress" > /run/nologin
ssh -t username@host /bin/bash