13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 6 ■ SECURING YOUR SYSTEMSpassword. Finally, the last three options (dcredit, ucredit, and lcredit) add the requirements that thenew password should contain at least one character from each of the character classes of digit, lowercasecharacter, and uppercase character.However, this policy won’t come into effect until a user changes their password, so if their passwordnever expires, they’ll probably never change it. To make all your users change their passwords regularly,edit the /etc/login.defs file to set the PASS_MAX_DAYS variable to the maximum time allowed beforechanging a password (in days).Finally, however, the change to /etc/login.defs affects only new accounts. To affect existing users,you need to use the command chage:# chage -M 90 -W 7 jkempThis will set the maximum number of days between password changes to 90 for the user jkemp andwill warn the user for the seven days in advance before their password will expire. This needs to be doneon an individual user basis, unfortunately, rather than as a system-wide policy. You can use awk togenerate a script for this:# cat /etc/passwd | awk -F: '{print "chage -M 90 -W 7 "$1}' > maxdaysCheck over the maxdays file to edit out system users, and then run the script with bash maxdays.6-10. Checking the Password PolicyOnce you’ve set the password policy, as in the previous recipes, it’s also worth occasionally checking thatpeople really are using reasonable passwords and that the policies aren’t letting weak passwordsthrough. john-the-ripper (available via most distros) is a password-cracking tool that identifiesvulnerable passwords before someone with nefarious intentions finds the weakness.If you’re using /etc/password-based security, the first step is to extract the username/passwordinformation from the relevant files using the provided unshadow tool:unshadow /etc/passwd /etc/shadow > /tmp/password.dbunshadow will produce a password database only on systems that use /etc/passwd and /etc/shadowfor login. For centralized systems, a Kerberos5 module is available, or the supplied unafs utility extractsKerberos AFS passwords. There’s also an LDAP module.After you’ve extracted your password database, john has three cracking modes:• Dictionary mode, which tests passwords based on dictionary words. You can usethe provided dictionary or provide your own, and there’s an option to enable“word mangling” rules.• “Single crack” mode, which uses login names and various /etc/passwd values aspassword candidates, as well as applying word mangling rules.• Incremental mode, which tries all possible character combinations and willobviously take a very, very long time to run. You’ll almost certainly need to stop itmanually eventually, unless you have a very short password limit. You can changethe parameters for this via the config file.147Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!