Linux - Password
Commands
Display password policy for an user:
/etc/shadow
How it work
Basically, the /etc/shadow file stores secure user account information.
All fields are separated by a colon (:) symbol. It contains one entry
per line for each user listed in /etc/passwd file.
lkone:$1$fnnfcFgTiHGOfff#5:13064:0:99999:7:::
#---- -------------------- ----- - ----- -
# 1 2 3 4 5 6
- Username
- Encrypted Password (
${id}${salt}${hashed}). Withid: $1$: md5$2a$: Blowfish$2y$: Blowfish$5$: sha-256$6$: sha-512- Last password change
- Minimum: The minimum number of days required between password changes.
- Maximum: The maximum number of days the password is valid.
- Warn: The number of days before password is to expire that user is warned.
- Inactive: The number of days after password expires that account is disabled.
- Expire: days since Jan 1, 1970 that account is disabled.
Verify Integrity
You can use pwck command verifies the integrity of the users and authentication information:
# Shadow file:
pwck -r /etc/shadow
# Passwd file:
pwck -r /etc/passwd
# Both
pwck -r /etc/passwd /etc/shadow
Generate Password
With openssl command:
With mkpasswd command:
With chpasswd command (Update existing password):
Random Password
With dd command:
With openssl command:
Links
- https://www.cyberciti.biz/faq/understanding-etcshadow-file/