A junior admin needs to ensure that the 'apache' user (UID 48) cannot log in via SSH or console. Which command achieves this?
Trap 1: passwd -l apache
Locks password but doesn't prevent SSH key login.
Trap 2: chage -l apache
Lists password expiry; does not restrict login.
Trap 3: usermod -e 1 apache
Setting the account expiration date to 1 (early epoch) immediately expires the account, which does prevent login immediately. However, this is not the preferred method because it disables all logins (including non-interactive) and is not the standard way to disable interactive logins for a service account. The recommended approach is to change the shell to /sbin/nologin.
- A
usermod -s /sbin/nologin apache
Sets shell to nologin, blocking interactive login.
- B
passwd -l apache
Why wrong: Locks password but doesn't prevent SSH key login.
- C
chage -l apache
Why wrong: Lists password expiry; does not restrict login.
- D
usermod -e 1 apache
Why wrong: Setting the account expiration date to 1 (early epoch) immediately expires the account, which does prevent login immediately. However, this is not the preferred method because it disables all logins (including non-interactive) and is not the standard way to disable interactive logins for a service account. The recommended approach is to change the shell to /sbin/nologin.