For posterity's sake:
So first:
sudo apt install -y libpam-pwdfile
If you don't have the "mkpasswd" command, then you need to install "whois" first
sudo apt install whois
Then take the username you use to log in, let's say "ben" and do this:
sudo -i
cp /etc/pam.d/gdm-password /etc/pam.d/gdm-password_ORIGINAL
echo "ben:$(mkpasswd -5)" > /etc/custompinfile
chmod 400 /etc/custompinfile
Then you need to edit /etc/pam.d/gdm-password (or other desktop manager or whatever, who cares, you'll figure it out, the thing that manages your logins, mine is gdm-password)
and add this line near the top, the top of my /etc/pam.d/gdm-password looks like this
#%PAM-1.0
auth sufficient pam_pwdfile.so pwdfile=/etc/custompinfile
Ue whatever, gedit, nano, vim, but you need sudo privileges to edit it.
Then I saved and quit and logged out and when I logged back in it only required the pin on the lock screen, but it didn't accept the pin when asking for sudo privileges, which is what we wanted, otherwise we would have simply set the password to 1234.
If you mess everything up, you can boot in recovery mode (if you don't have a dual boot with Windows, I think it is something like pressing Shift while it's starting up, then there will be a menu to choose recovery mode, in recovery mode you can simply access the shell as root and revert the /etc/pam.d/gdm-password back to it's original state, if you remember it ;-) That's why it's maybe a good idea to make a backup of the original gdm-password file like cp /etc/pam.d/gdm-password /etc/pam.d/gdm-password_ORIGINAL
Remember, the /etc/custompinfile can be called anything, but the contents inside need to be in this format: user:hashedpassword
And the hashed password is obtained using mkpasswd -5 when you install the whois package and run it.
auth sufficient pam_pwdfile.so pwdfile=/etc/custompinfile
to the top of/etc/pam.d/sudo
– miigotu Mar 06 '21 at 09:11/etc/custompinfile
can EASILY brute force the PIN. Therefore make sure that the file is owned by root and nobody else has access to it (440 mod I think).Also, if the drive where
– Ezra Steinmetz May 01 '22 at 09:47/etc/custompinfile
is stored isn't encrypted - in case somebody gains physical access to the drive he will be able to access the file (and brute force the PIN) regardless of the permissions you've set to the file.