Suppose we want to take a backup of user’s account. So for that first of all we have to block the user to login into their account to maintain data integrity of user’s backup files. So using below technique we can do that very easily.enjoy !!!
Edit the pam file located in /etc/pam.d/ directory for the service you want to control.
Example : Suppose you want to do control ssh service
Step 1: Add below line in /etc/pam.d/sshd file if it is not available.
account required pam_nologin.so
Step 2: Create the /etc/nologin file,
# touch /etc/nologin
This should disable the login from ssh for every user except administrator user(root).
Step 3: To re-enable the login just remove /etc/nologin
# rm –rf /etc/nologin
Recent Comments