Hardening guidelines for /etc/shadow files are as follows.
1) It should be owned by root and have permission of 600 or more restrictive.
e.g.
# ls -l /etc/shadow-r-------- 1 root root 890 Sep 28 05:29 /etc/shadowIn above case its more restrictive i.e. 400 even root is not given write access by default.
2) Each Line must contain a unique user name and should not contain any blank line.
3) First two fields i.e username and password should not be blank.
4) Password filed should be more than 13-24 Character long.
e.g.
admin:$1$YSmsjgr7$m3YjwsZNdQ/Z24QXGWj8O1:14879:0:99999:7:::"$1$" it means the MD5-based algorithm was used while encrypting the password.
5) Password for root account should not be assigned to any other account.
6) All locked accounts must have a single exclamation mark "!" as the first character of the Passwd field.
for example.
following are some lines from /etc/shadow file.
vcsa:!!:14866:0:99999:7:::sshd:!!:14866:0:99999:7:::ftp:*:14866:0:99999:7:::nobody:*:14866:0:99999:7:::bkpadmin:$1$IgKNf9Xa$fvt5T9rIOzLxe9yvU9i870:14882:0:99999:7:::There counterparts in /etc/passwd file.
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologinsshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologinftp:x:14:50:FTP User:/var/ftp:/sbin/nologinnobody:x:99:99:Nobody:/:/sbin/nologinbkpadmin:x:500:500::/home/bkpadmin:/sbin/nologinhere are the status of the username.
# passwd -S vcsavcsa LK 2010-09-14 0 99999 7 -1 (Password locked.)# passwd -S sshdsshd LK 2010-09-14 0 99999 7 -1 (Password locked.)# passwd -S ftpftp LK 2010-09-14 0 99999 7 -1 (Alternate authentication scheme in use.)# passwd -S nobodynobody LK 2010-09-14 0 99999 7 -1 (Alternate authentication scheme in use.)# passwd -S bkpadminbkpadmin PS 2010-09-30 0 99999 7 -1 (Password set, MD5 crypt.)statusStatus of the name:
PS = Passworded
LK = Locked
NP = No Password
as you can see.
vcsa and sshd both have ! as first character in password filed (2nd field).This is well justified using passwd -S
.
7) Application accounts which are not locked must contain only an asterisk “*” in the Passwd field.
For example.
ftp:*:14866:0:99999:7:::nobody:*:14866:0:99999:7:::
Above users are used for application and hence they are locked but Alternate authentication is used for them.
# passwd -S ftpftp LK 2010-09-14 0 99999 7 -1 (Alternate authentication scheme in use.)# passwd -S nobodynobody LK 2010-09-14 0 99999 7 -1 (Alternate authentication scheme in use.)More on this soon...