Skip to content

Instantly share code, notes, and snippets.

@ju916
Last active April 18, 2019 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ju916/ce58e0ce5c80030a34154ec48793cdc5 to your computer and use it in GitHub Desktop.
Save ju916/ce58e0ce5c80030a34154ec48793cdc5 to your computer and use it in GitHub Desktop.
Script to create a user database suitable for pam_userdb
#!/bin/bash
#
# create a user database suitable for pam_userdb
# usage:
# mk-pinlist.sh [user] [db file]
USR=${1:-`who | grep ':0' | head -1 | awk '{print $1}'`}
shift
DB=${1:-'/etc/pinlist.db'}
HASH=`mkpasswd -s -m sha-512`
{ echo $USR; echo $HASH; } | db_load -T -t hash $DB
chmod 0600 $DB
echo "Current content:"
echo "================"
db_dump -p $DB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment