Deny All Access in One Second or Less
Posted by arun161087 on August 25, 2008
The first method is by far the quickest. Just run the following command (as root):
# touch /etc/nologin
This will deny access to anyone trying to log in to the machine. You’ll want to be sure to keep an active login session on the machine after you create this file or make sure that root is allowed to log in on the local console or via SSH, since a root login will bypass this mechanism. You’ll know it’s working because the logs for some services will tell you that access was denied because of the presence of the nologin file. Others will just say “failed password.”
This method can be improved through the use of a nologin.txt file, where you can put some text that users will see when they try to log in. If you have a scheduled downtime, for instance, you can put the details into this file so that users will get a friendly reminder that the machine is unavailable during the downtime window.
Create a file called /etc/hosts.deny.ALL, which should consist of only one line:
##### /etc/hosts.deny.ALL
ALL:ALL@ALL