CompTIA Linux+ (XK0-005) — Question 253
Which of the following will prevent non-root SSH access to a Linux server?
Answer options
- A. Creating the /etc/nologin file
- B. Creating the /etc/nologin.allow file containing only a single line root
- C. Creating the /etc/nologin/login.deny file containing a single line +all
- D. Ensuring that /etc/pam.d/sshd includes account sufficient pam_nologin.so
Correct answer: A
Explanation
Creating the /etc/nologin file effectively prevents all non-root users from logging in to the server, as it signals that the system is not accepting non-root user logins. The other options either do not effectively restrict access or are incorrectly configured to allow certain users access rather than blocking all non-root connections.