Preventing Interactive Login Sessions on Linux Systems

Preventing Interactive Login Sessions

Question

Which of the following steps prevents a user from obtaining an interactive login session?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

A

The correct answer is E. Create a .nologin file in the user's home directory.

Explanation: A user can obtain an interactive login session on a Linux system by accessing the system either locally or remotely, such as through SSH. To prevent a user from obtaining an interactive login session, you can take various measures. Let's examine each answer option and why it is or is not a valid solution:

A. Run the command chsh -s /bin/false with the user name. This command changes the user's login shell to /bin/false, which prevents them from obtaining an interactive login session. However, the user can still log in and run non-interactive commands, such as running a script, so this is not a complete solution.

B. Set the UID for the user to 0. Setting a user's UID to 0 makes them a superuser, but it does not prevent them from obtaining an interactive login session. In fact, it gives them more privileges.

C. Remove the user from the group staff. Removing a user from a group does not prevent them from obtaining an interactive login session. It only affects their group membership and associated permissions.

D. Add the user to /etc/noaccess. There is no standard system file called /etc/noaccess. This answer option is incorrect.

E. Create a .nologin file in the user's home directory. This is the correct answer. Creating a .nologin file in the user's home directory prevents them from obtaining an interactive login session. If the file exists, the system displays its contents to the user and exits the login process, effectively denying them access. The contents of the .nologin file are customizable, so you can provide a customized message to the user.

In summary, the correct answer is E. Create a .nologin file in the user's home directory.