Skip to content

Instantly share code, notes, and snippets.

@dmcbane
Last active October 29, 2025 06:09
Show Gist options
  • Select an option

  • Save dmcbane/3ce77630e5070dc87ce777fc71c1ea72 to your computer and use it in GitHub Desktop.

Select an option

Save dmcbane/3ce77630e5070dc87ce777fc71c1ea72 to your computer and use it in GitHub Desktop.
Setup Ubuntu for PIN login

Setup Ubuntu for PIN Login Instead of Long Password

  • Install packages if they aren't already installed.
sudo apt install libpam-pwdfile whois
  • Backup the Original PAM Configuration File
sudo cp /etc/pam.d/gdm-password /etc/pam.d/gdm-password_ORIGINAL
  • Create the Custom PIN File
echo "$(whoami):$(mkpasswd -5)" | sudo tee /etc/custompinfile
sudo chmod 400 /etc/custompinfile
  • Edit the PAM Configuration File to Enable the PIN file

Use your editor of choice with superuser privileges to edit the /ect/pam.d/gdm-password file to add auth sufficient pam_pwdfile.so pwdfile=/etc/custompinfile to the top of the file, similar to the following:

sudo vim /etc/pam.d/gdm-password

The top of your configuration file should look like the following:

#%PAM-1.0
auth    sufficient      pam_pwdfile.so  pwdfile=/etc/custompinfile
@benjaminoakes
Copy link

Thank you! It's working as expected immediately after setup. Shared here: https://www.benjaminoakes.com/2025/06/04/Setup-Ubuntu-for-PIN-Login-Instead-of-Long-Password/

@looeee
Copy link

looeee commented Jul 20, 2025

After logging in with the pin, I get this screen (clicking cancel does nothing) and I have to enter the full password anyway.

image

@benjaminoakes
Copy link

Yes, that happens on first login. Same as with fingerprint login. Unlocking the screen with PIN or fingerprint will not require unlocking the keyring.

So, after a reboot, log in with password. After locking the screen, use PIN or fingerprint.

@PaSSw0rds
Copy link

LGTM! You have saved my life!

@karolzlot
Copy link

@looeee
Copy link

looeee commented Sep 13, 2025

Does PIN require Enter to confirm when using this solution?

Yes

@looeee
Copy link

looeee commented Sep 30, 2025

Unfortunately after several weeks of using this, I had to revert it. It doesn't work well with fscrypt encrypted folders or drives. I found myself jumping through all kinds of hoops to get it to work, and for safety decided that I should just go back to the main password rather than end up locking myself out.

I think it's safe to say that at this point, Ubuntu isn't designed to work with pin access for the initial login, and you should only use this on an intentionally insecure system without any encrypted files, stored credit card details, etc.

However, it might be possible to set things up so you enter the main password on the first login (after a reboot). This will unlock encrypted drives and keyring. Then use the pin screen lock only. I'll investigate this when I have more time.

@benjaminoakes
Copy link

@looeee said:

However, it might be possible to set things up so you enter the main password on the first login (after a reboot). This will unlock encrypted drives and keyring. Then use the pin screen lock only. I'll investigate this when I have more time.

That's what I do (see above). I may have different needs than you, but I know I at least don't need to provide a password for the keyring if I first log in with a password and then use PIN/fingerprint to unlock the screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment