5.4.2 Ensure system accounts are non-login

Information

There are a number of accounts provided with Aliyun Linux 2 that are used to manage applications and are not intended to provide an interactive shell.

Rationale:

It is important to make sure that accounts that are not being used by regular users are prevented from being used to provide an interactive shell. By default Aliyun Linux 2 sets the password field for these accounts to an invalid string, but it is also recommended that the shell field in the password file be set to /sbin/nologin . This prevents the account from potentially being used to run any commands. Some built-in accounts use /bin/false which is also acceptable. This prevents the account from potentially being used to run any commands.

Solution

Set the shell for any accounts returned by the audit script to /sbin/nologin :

# usermod -s /sbin/nologin <user>
The following script will automatically set all user shells required to /sbin/nologin and lock the sync , shutdown , and halt users:
#!/bin/bash

for user in `awk -F: '($3 < 1000) {print $1 }' /etc/passwd` ; do
if [ $user != "root" ]; then
usermod -L $user
if [ $user != "sync" ] && [ $user != "shutdown" ] && [ $user != "halt" ]; then
usermod -s /sbin/nologin $user
fi
fi
done

See Also

https://workbench.cisecurity.org/files/2449

Item Details

Category: CONFIGURATION MANAGEMENT

References: 800-53|CM-6, CSCv7|5.1

Plugin: Unix

Control ID: d507d9c957d0b6e9c3926f771123806d13c82d9615929af33143dba033a5d2b1