Debian based Linux Account Policies
Default minimum password age
Section titled “Default minimum password age”sudo nano /etc/login.defsAdd the following or change the existing:
PASS_MIN_DAYS = 2Minimum password length
Section titled “Minimum password length”sudo nano etc/pam.d/common-passwordAdd the following or change the existing:
password ⇥ requisite ⇥ pam_pwquality.so retry=3 minlen=10Account lockout policy
Section titled “Account lockout policy”Lets add 2 new policies to PAM
Add faillock
Section titled “Add faillock”sudo touch /usr/share/pam-configs/faillocksudo nano /usr/share/pam-configs/faillockAdd the following to /usr/share/pam-configs/faillock:
Name: Enforce failed login attempt counterDefault: noPriority: 0Auth-Type: PrimaryAuth: [default=die] pam_faillock.so authfail sufficient pam_faillock.so authsuccAdd faillock_notify
Section titled “Add faillock_notify”sudo touch /usr/share/pam-configs/faillock_notifysudo nano /usr/share/pam-configs/faillock_notifyAdd the following to /usr/share/pam-configs/faillock_notify:
Name: Notify on failed login attemptsDefault: noPriority: 1024Auth-Type: PrimaryAuth: requisite pam_faillock.so preauthTurn on new policies
Section titled “Turn on new policies”sudo pam-auth-updateSelect the following in the list:
[X] Notify on failed login attempts[X] Enforce failed login attempt counter
Do not allow null passwords
Section titled “Do not allow null passwords”sudo nano /etc/pam.d/common-authRemove nullok
auth [success=2 default=ignore] pam_unix.so nullokauth [success=2 default=ignore] pam_unix.soSecure /etc/shadow
Section titled “Secure /etc/shadow”First lets list out all files, folders, pipes, etc:
ls -alF /etc/shadowExample output:
-rw-r----- 1 root shadow 866 May 24 2022 /etc/shadowNow secure it:
sudo chmod 640 /etc/shadowipv4 policies
Section titled “ipv4 policies”sudo nano /etc/sysctl.confAdd the following to /etc/sysctl.conf
net.ipv4.tcp_syncookies=1net.ipv4.ip_forward=0And then reload settings:
sudo sysctl --systemDisable services
Section titled “Disable services”Disable nginx web server
sudo systemctl disable --now nginxDisable vsftpd aka Very Secure File Transfer Protocol Daemon
sudo systemctl disable --now vsftpd