Password Policy in RHEL7



In Red Hat Enterprise Linux 7, the pam_pwquality PAM module replaced pam_cracklib, which was used in Red Hat Enterprise Linux 6 as a default module for password quality checking. It uses the same back end as pam_cracklib.

The code was originally based on pam_cracklib module, and the module is backwards compatible with its options.

The pam_pwquality module can be customized and configured in the file /etc/security/pwquality.conf.
The possible options in the file are:

difok
Number of characters in the new password that must not be present in the old password. (default 5)

minlen
Minimum acceptable size for the new password (plus one if credits are not disabled which is the default). (See pam_pwquality(8).) Cannot be
set to lower value than 6. (default 9)

dcredit
The maximum credit for having digits in the new password. If less than 0 it is the minimum number of digits in the new password. (default 1)

ucredit
The maximum credit for having uppercase characters in the new password. If less than 0 it is the minimum number of uppercase characters in
the new password. (default 1)

lcredit
The maximum credit for having lowercase characters in the new password. If less than 0 it is the minimum number of lowercase characters in
the new password. (default 1)

ocredit
The maximum credit for having other characters in the new password. If less than 0 it is the minimum number of other characters in the new
password. (default 1)

minclass
The minimum number of required classes of characters for the new password (digits, uppercase, lowercase, others). (default 0)

maxrepeat
The maximum number of allowed same consecutive characters in the new password. The check is disabled if the value is 0. (default 0)

maxsequence
The maximum length of monotonic character sequences in the new password. Examples of such sequence are ‘12345’ or ‘fedcb’. Note that most
such passwords will not pass the simplicity check unless the sequence is only a minor part of the password. The check is disabled if the
value is 0. (default 0)

maxclassrepeat
The maximum number of allowed consecutive characters of the same class in the new password. The check is disabled if the value is 0.
(default 0)

gecoscheck
If nonzero, check whether the words longer than 3 characters from the GECOS field of the user’s passwd entry are contained in the new pass‐
word. The check is disabled if the value is 0. (default 0)

badwords
Space separated list of words that must not be contained in the password. These are additional words to the cracklib dictionary check. This
setting can be also used by applications to emulate the gecos check for user accounts that are not created yet.

dictpath
Path to the cracklib dictionaries. Default is to use the cracklib default.

SEE ALSO
pwscore(1), pwmake(1), pam_pwquality(8)


PAM, pam – Pluggable Authentication Modules for Linux

The password policy in RHEL 7, and most other linux distributions, is handled by the PAM (Pluggable Authentication Modules) system. The dynamically-configurable system can be modified in /etc/pam.conf and /etc/pam.d/.

Linux-PAM separates the tasks of authentication into four independent management groups: account management; authentication management; password management; and session management. (We highlight the abbreviations used for
these groups in the configuration file.)

Simply put, these groups take care of different aspects of a typical user’s request for a restricted service:

account – provide account verification types of service: has the user’s password expired?; is this user permitted access to the requested service?

authentication – authenticate a user and set up user credentials. Typically this is via some challenge-response request that the user must satisfy: if you are who you claim to be please enter your password. Not all
authentications are of this type, there exist hardware based authentication schemes (such as the use of smart-cards and biometric devices), with suitable modules, these may be substituted seamlessly for more standard
approaches to authentication – such is the flexibility of Linux-PAM.

password – this group’s responsibility is the task of updating authentication mechanisms. Typically, such services are strongly coupled to those of the auth group. Some authentication mechanisms lend themselves well to being
updated with such a function. Standard UN*X password-based access is the obvious example: please enter a replacement password.

session – this group of tasks cover things that should be done prior to a service being given and after it is withdrawn. Such tasks include the maintenance of audit trails and the mounting of the user’s home directory. The
session management group is important as it provides both an opening and closing hook for modules to affect the services available to a user.

cat /etc/pam.d/system-auth
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_fprintd.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 1000 quiet_success
auth        required      pam_deny.so

account     required      pam_unix.so
account     sufficient    pam_localuser.so
account     sufficient    pam_succeed_if.so uid < 1000 quiet
account     required      pam_permit.so

password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
-session     optional      pam_systemd.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so


There are a number of different options that are placed in the /etc/pam.d/system-auth file that allows system administrators to further customize the implementation of the various modules in PAM. The following options are available for the pam_pwquality module:

debug
This option makes the module write information to syslog(3) indicating the behavior of the module (this option does not write password informa‐
tion to the log file).

authtok_type=XXX
The default action is for the module to use the following prompts when requesting passwords: “New UNIX password: ” and “Retype UNIX password: “.
The example word UNIX can be replaced with this option, by default it is empty.

retry=N
Prompt user at most N times before returning with error. The default is 1.

difok=N
This argument will change the default of 5 for the number of changes in the new password from the old password.

minlen=N
The minimum acceptable size for the new password (plus one if credits are not disabled which is the default). In addition to the number of char‐
acters in the new password, credit (of +1 in length) is given for each different kind of character (other, upper, lower and digit). The default
for this parameter is 9 . Note that there is a pair of length limits also in Cracklib, which is used for dictionary checking, a “way too short”
limit of 4 which is hard coded in and a build time defined limit (6) that will be checked without reference to minlen.

dcredit=N
(N >= 0) This is the maximum credit for having digits in the new password. If you have less than or N digits, each digit will count +1 towards
meeting the current minlen value. The default for dcredit is 1 which is the recommended value for minlen less than 10.

(N < 0) This is the minimum number of digits that must be met for a new password.

ucredit=N
(N >= 0) This is the maximum credit for having upper case letters in the new password. If you have less than or N upper case letters each letter
will count +1 towards meeting the current minlen value. The default for ucredit is 1 which is the recommended value for minlen less than 10.

(N < 0) This is the minimum number of upper case letters that must be met for a new password.

lcredit=N
(N >= 0) This is the maximum credit for having lower case letters in the new password. If you have less than or N lower case letters, each let‐
ter will count +1 towards meeting the current minlen value. The default for lcredit is 1 which is the recommended value for minlen less than 10.

(N < 0) This is the minimum number of lower case letters that must be met for a new password.

ocredit=N
(N >= 0) This is the maximum credit for having other characters in the new password. If you have less than or N other characters, each character
will count +1 towards meeting the current minlen value. The default for ocredit is 1 which is the recommended value for minlen less than 10.

(N < 0) This is the minimum number of other characters that must be met for a new password.

minclass=N
The minimum number of required classes of characters for the new password. The default number is zero. The four classes are digits, upper and
lower letters and other characters. The difference to the credit check is that a specific class if of characters is not required. Instead N out
of four of the classes are required.

maxrepeat=N
Reject passwords which contain more than N same consecutive characters. The default is 0 which means that this check is disabled.

maxsequence=N
Reject passwords which contain monotonic character sequences longer than N. The default is 0 which means that this check is disabled. Examples
of such sequence are ‘12345’ or ‘fedcb’. Note that most such passwords will not pass the simplicity check unless the sequence is only a minor
part of the password.

maxclassrepeat=N
Reject passwords which contain more than N consecutive characters of the same class. The default is 0 which means that this check is disabled.

gecoscheck=N
If nonzero, check whether the individual words longer than 3 characters from the passwd GECOS field of the user are contained in the new pass‐
word . The default is 0 which means that this check is disabled.

badwords=’list of words’
The words more than 3 characters long from this space separated list are individually searched for and forbidden in the new password. By
default the list is empty which means that this check is disabled.

enforce_for_root
The module will return error on failed check even if the user changing the password is root. This option is off by default which means that just
the message about the failed check is printed but root can change the password anyway. Note that root is not asked for an old password so the
checks that compare the old and new password are not performed.

local_users_only
The module will not test the password quality for users that are not present in the /etc/passwd file. The module still asks for the password so
the following modules in the stack can use the use_authtok option. This option is off by default.

use_authtok
This argument is used to force the module to not prompt the user for a new password but use the one provided by the previously stacked password
module.

dictpath=/path/to/dict
Path to the cracklib dictionaries.


An additional configuration file worth mentioning within the context of password policy is the /etc/login.defs file; it’s provided by the setup package. The /etc/login.defs file defines the site-specific configuration for the shadow password suite. Though, it’s not part of the PAM system, this file is required; absence of it will not
prevent system operation, but will probably result in undesirable operation.

More on this


Advertisements

Audio Playback in AwesomeWM

As a Window Manager, awesome-wm‘s lightweight composition
results in a more-responsive user experience as compared to a full-fledged Desktop Environment like
Gnome, for example. However, depending on your needs, lightweight might also be described
as stripped down; your expectations of what simply “works” (or should work) right out
the gate in a graphical desktop session, without any user input, may be misguided, as I found mine
to be today after attempting to watch a YouTube video with no apparent sound.

Puzzled by the strange
effect, I clicked on another, different, random video, restarted my browser, cleared the cache, tested
the audio output with VLC media player to ascertain the persistence of the problem. It seemed
inconceivable to me that I hadn’t noticed this behavior before, especially, because I had been using awesome-wm for years it seemed! Alas, ’twas so afterall.

Here’s how I managed to
fix the problem with Audio playback on my Fedora20 system.


First, make sure that your user is in the audio, pulse, and pulse-access
groups; if not, execute the following as root

    # usermod -a -G audio myusername
    # usermod -a -G pulse myusername
    # usermod -a -G pulse-access myusername

Then, edit ~/.xinitrc, if you’re starting awesome-wm from console, and add the following line:

    start-pulseaudio-X11
 

Kill the pulseaudio process, log out and log in again–I ended up simply rebooting the system, instead.

As a hidden Easter Egg, for those who made it to the end of this post, take a look at Farhavens volume widget over on the
awesome-wm wiki pages .

NOTE: `start-pulseaudio-X11` is, actually, a script in the `/bin/` directory.

Reset Root Pass in RHEL7

Without a doubt, one of the most powerful and essential tools a system’s administrator has is the ability to gain root privileges. While it’s generally a bad idea, to say the least, to perpetually operate as the root user on any given system, being able to log in as the root user on the command console is essential at times. Therefore, it’s frustrating to be in the position as a system administrator if you’ve forgotten or otherwise lost the password and are, subsequently, unable to gain escalated privileges on a system.

Since the shift to grub2, as well as other changes with the init system, the method of gaining access to a system for such low-level purposes has changed .

Reboot the system, wait for the grub menu, press the letter ‘E’ on the keyboard to edit the menuentry. Then, scroll down to the bottom of the screen to the line starting with linux
and append the space-separated kernel commands rw and init=/bin/bash
before hitting the F10 key to boot the edited menu entry.
enter image description here
This will boot the system into a bash shell with the root partition mounted in
rw mode (read-write permissions).
enter image description here
NOTE: The previously-advised method of booting into single user mode, or
runlevel 1 should not be advised, as the rescue-shell now expects the user to enter
the root password before allowing access to it.
Booting the system using bash will allow the user to finally change the password
with the appropriate

    # passwd

command.
Furthermore, however, in order to make sure that SELinux file contexts are
restored properly after the password modification, execute:

    # touch /.autorelabel

before restarting the virtual system.
To restart the virtual machine, execute

    # /sbin/reboot -f

Backups in RHEL7

The default storage setup in a new Red Hat Enterprise Linux 7 installation is an LVM partitioning scheme with an XFS boot partition outside of the LVM scheme, and the root and home partitions comprising the main volume group on an XFS filesystem. This is a departure from the previous default filesystem type ext4.
<img alt="RHEL7-partition_scheme" src="https://i1359.photobucket .com/albums/q783/ILMostro7/Web-tech/rhel7-partition_scheme_zps490fabd9.png” title=”RHEL7-partition_scheme”>
Some important behavioral and administrative differences between the ext4 filesystem and the xfs filesystem are addressed in the RedHat Documentation, chapter 6 in the “Storage Administration Guide” specifically. The key items addressed pertain to Filesystem repair, Metadata error behavior, Quotas, Filesystem resize and Inode numbers among other things.
One nice feature of the XFS filesystem is the native backup and restoration feature with the xfsdump and xfsrestore utilities, respectively. The xfsdump utility supports incremental backups to tape drives or regular file images. The incremental backups are possible due to the use of different dump levels. To perform a full backup, a level 0 (zero) dump, of the root (/) filesystem, execute

xfsdump -l 0 -f /dev/tape /

To restore the root filesystem from a locally-mounted tape drive, execute

xfsrestore -f /dev/tape /

There’s a nice write-up about this and other useful features and utilities pertaining to the XFS filesystem on unixarena.com.


Example System Backup

I have an SSD as my primary drive (/dev/sda) with the RHEL7 system installed on 2 physical partitions: boot and the LVM rootfs. I also have a second HDD (/dev/sdb) with partitions for various purposes. I’m going to create a new primary partition of type “Linux LVM” in the free space of /dev/sdb, make it part of a new VolumeGroup with a new Logical Volume, then make the Logical Volume an XFS partition filesystem for backup purposes. Creating the primary partition can be done in a number of different ways, including software with a GUI; I did that with gparted instead of commandline tools, so I’ll skip that part here. As for the remainder of the steps, here it goes:

[04:40][1004]# vgcreate mostrovg /dev/sdb3
  Volume group "mostrovg" successfully created
[04:41][1005]# vgs
  VG             #PV #LV #SN Attr   VSize  VFree 
  mostrovg         1   0   0 wz--n- 24.41g 24.41g
  rhel             1   2   0 wz--n- 77.98g     0
[04:39][1002]# pvs
  PV         VG             Fmt  Attr PSize  PFree 
  /dev/sda5  rhel         lvm2 a--  77.98g     0 
  /dev/sdb3
[04:45][1008]# lvcreate -L 15G mostrovg 
  Logical volume "lvol0" created
[04:46][1009]# lvs
  LV    VG             Attr       LSize  Pool Origin    Data%  Move Log Cpy%Sync Convert
  lvol0 mostrovg       -wi-a----- 15.00g                                             
  home  rhel           -wi-ao---- 27.98g                                             
  root  rhel           -wi-ao---- 50.00g
[04:47][1011]# mkfs.xfs /dev/mostrovg/lvol0 
meta-data=/dev/mostrovg/lvol0    isize=256    agcount=4, agsize=983040 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=3932160, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[04:48][1014]# mkdir /new_xfs
[04:49][1015]# mount -t xfs /dev/mostrovg/lvol0 /new_xfs
[04:49][1016]# df -h /new_xfs
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/mostrovg-lvol0        15G   33M   15G   1% /new_xfs
[04:49][1017]# xfsdump -l 0 -f /new_xfs/redhatsys_xfs_dump /                    [1/848]
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.3 (dump format 3.0) - type ^C for status and control

 ============================= dump label dialog ==============================

please enter label for this dump session (timeout in 300 sec)
 -> first-backup
session label entered: "first-backup"

 --------------------------------- end dialog ---------------------------------

xfsdump: level 0 dump of RedHatSys:/
xfsdump: dump date: Sun Dec 21 04:53:41 2014
xfsdump: session id: 9931f48f-b871-433f-a293-b95a50c0f8f1
xfsdump: session label: "first-backup"
xfsdump: ino map phase 1: constructing initial dump list
xfsdump: WARNING: failed to get bulkstat information for inode 12873
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 310370
xfsdump: WARNING: failed to get bulkstat information for inode 1156827
xfsdump: WARNING: failed to get bulkstat information for inode 1156827
xfsdump: WARNING: failed to get bulkstat information for inode 1156960
xfsdump: WARNING: failed to get bulkstat information for inode 1160639
xfsdump: WARNING: failed to get bulkstat information for inode 1160642
xfsdump: WARNING: failed to get bulkstat information for inode 68027677
xfsdump: WARNING: failed to get bulkstat information for inode 68027680
xfsdump: WARNING: failed to get bulkstat information for inode 70312711
xfsdump: WARNING: failed to get bulkstat information for inode 70312711
xfsdump: WARNING: failed to get bulkstat information for inode 135342967
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 202323245
xfsdump: WARNING: failed to get bulkstat information for inode 204649308
xfsdump: WARNING: failed to get bulkstat information for inode 204649308
xfsdump: WARNING: failed to get bulkstat information for inode 204747323
xfsdump: ino map phase 2: skipping (no pruning necessary)
xfsdump: ino map phase 3: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: estimated dump size: 7147530560 bytes
xfsdump: /var/lib/xfsdump/inventory created

 ============================= media label dialog =============================

please enter label for media in drive 0 (timeout in 300 sec)
 -> 12212014
media label entered: "12212014"

 --------------------------------- end dialog ---------------------------------

xfsdump: creating dump session media file 0 (media 0, file 0)
xfsdump: dumping ino map
xfsdump: dumping directories
xfsdump: dumping non-directory files
xfsdump: ending media file
xfsdump: media file size 6888970064 bytes
xfsdump: dump size (non-dir files) : 6748694032 bytes
xfsdump: dump complete: 100 seconds elapsed
xfsdump: Dump Summary:
xfsdump:   stream 0 /new_xfs/redhatsys_xfs_dump OK (success)
xfsdump: Dump Status: SUCCESS

Full backup of the root partition finished successfully!

Display the xfsdump inventory to check the possibilities to restore, if needed:

[05:36][1020]# xfsrestore -I
file system 0:
        fs id:          5f6d031e-204b-4c7e-b7e4-96b1bd22a33a
        session 0:
                mount point:    RedHatSys:/
                device:         RedHatSys:/dev/mapper/rhel-root
                time:           Sun Dec 21 04:53:41 2014
                session label:  "first-backup"
                session id:     9931f48f-b871-433f-a293-b95a50c0f8f1
                level:          0
                resumed:        NO
                subtree:        NO
                streams:        1
                stream 0:
                        pathname:       /new_xfs/redhatsys_xfs_dump
                        start:          ino 134 offset 0
                        end:            ino 208435808 offset 0
                        interrupted:    NO
                        media files:    1
                        media file 0:
                                mfile index:    0
                                mfile type:     data
                                mfile size:     6888970064
                                mfile start:    ino 134 offset 0
                                mfile end:      ino 208435808 offset 0
                                media label:    "12212014"
                                media id:       cb09071b-bb40-4e7d-a268-7232090cad24
xfsrestore: Restore Status: SUCCESS

Great! So, if we wanted, or needed, to restore the filesystem from the previously-listed backup, we’d execute:

xfsrestore -f /new_xfs/redhatsys_xfs_dump -S 9931f48f-b871-433f-a293-b95a50c0f8f1 -r /