Archive for December 23rd, 2016

In some cases, you might want to block all users from logging in to the system or just after you login, you want to prevent everyone else from connecting to the server. During server maintenance, this could be helpful or there are use cases where only one actively logged in user has to do some work if the username is a shared account.

Solution – create the /etc/nologin file, and put the text notice as the body of the file. If a user attempts to log in to a system where this file exists, the contents of the nologin file is displayed, and the user login is terminated.

[root@kauai ~]# echo 'System is under maintenance till Dec. 24, 2PM EST.' > /etc/nologin

Now try to login to the server under non super user –

daniel@linubuvma:~$ ssh ns2
System is under maintenance till Dec. 24, 2PM EST.
Connection closed by

If your ssh configuration allows it, root user can login to the server though, the root user will still be greeted with the contents of /etc/nologin file though –

daniel@linubuvma:~$ ssh root@ns2
root@ns2's password:
System is under maintenance till Dec. 24, 2PM EST.
Last login: Sat Dec 12 01:11:35 2015 from
[root@kauai ~]# 

Reference –

During user login, a Linux box might show message of the day(motd), new email, or package updates information. This is particularly common in Ubuntu boxes. In some cases, you want to prevent all these messages from being displayed as it could be delaying your login for instance.

Solution – Create a file named .hushlogin in the user’s home directory.

A typical login to an Ubuntu box might look like this –

[daniel@kauai etc]$ ssh practice
daniel@practice's password: 
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-39-generic x86_64)

 * Documentation:

  System information as of Sat Jan 10 11:37:24 EST 2015

  System load:  0.0                Processes:           290
  Usage of /:   46.1% of 45.15GB   Users logged in:     1
  Memory usage: 13%                IP address for eth0:
  Swap usage:   0%

  Graph this data and manage this system at:

168 packages can be updated.
63 updates are security updates.

You have new mail.
Last login: Sat Jan 10 11:37:26 2015 from linux.local

To suppress all this information, create a .hushlogin file in the users home directory and log out and login back –

daniel@linubuvma:~$ touch ~/.hushlogin

daniel@linubuvma:~$ exit
Connection to practice closed.

[daniel@kauai etc]$ ssh practice
daniel@practice's password: