FreeBSD: Finding passwordless (no password) account and lock all accounts
It is necessary to check for passwordless accounts (i.e. search for no password entries and lock all accounts.) for security reasons. However, FreeBSD does not come with any command that can help you to find out all such accounts. FreeBSD stores password in /etc/master.passwd file. You can use awk to find out all passwordless account. Login in as root user and type following command:
awk -F: 'NF > 1 && $1 !~ /^[#+-]/ && $2=="" {print $0}'
/etc/master.passwd
s2099ms::1099:1099::0:0:User &:/home/s/s2099ms:/bin/bash
Where
NF : Total number of record (so only continue if we have more than one record in password file)
$1 : First field in /etc/master.passwd
$2 : Second filed in /etc/master.passwd
$1 !~ /^[#+-]/ : It compares first field (user login name) and make sure it does not starts with either +,- or # symbol
How does it work?
1) Awk statement read each line in /etc/master.passwd where fields separated by : symbol
2) Account has no password if password field ($2) in /etc/master.passwd is empty
Once you found all such passwordless account., you can Lock user account with the following command:
pw lock {username}
# pw lock s2099ms
For unlocking the account use:
pw unlock {username}
# pw unlock s2099ms
Related articles:
You may also be interested in other helpful articles:
- Search for all account without password and lock them
- FreeBSD: Password expiry / aging policy
- Increase security by Locking Admin screen/console
- First taste of HP-UX system administration
- Linux: How to create multiple users accounts in batch
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!


Recent Comments
Today ~ 28 Comments
Today ~ 2 Comments
Yesterday ~ 24 Comments
Yesterday ~ 24 Comments
Yesterday ~ 3 Comments