Home > Linux > How to Enable or Disable Login Messages

How to Enable or Disable Login Messages

Suppressing Login Messages

I do a lot of remote remote maintenance via ssh on my machines and one thing that I’ve long wondered about is the message outputted when you login.  You know, the system information output plus the notice concerning the warranty, etc.  Here is the output I’m referring to when connecting to my Sun Sparc Ultra 10 server via ssh:

Linux sparc 2.6.15-51-sparc64 #1 Tue Oct 23 21:46:00 UTC 2007 sparc64 GNU/Linux

The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
Last login: Sun Dec  9 12:50:43 2007 from 192.168.0.6

Now, that information is not ultra annoying by any means, but sometimes after repeated connections I just really don’t want to see it.  So, I finally found way that the information above can be suppressed.  All you need to do is create an empty file in your home folder and those login messages will be suppressed.

touch .hushlogin

Run that command, which just “touches” a file into creation with no contents.  If the login system finds that file it’ll suppress the login message above.  Note: if you want login messages suppressed on remote machines you need to create this file on the remote end.

Enabling Login Messages

The login message above actually comes from a file on the machine at /etc/motd.  If you’d like to change the message on your machine you can simply edit that file.

sudo vim /etc/motd

If you’d like to enable a different login message, which can often be used to pass messages to anyone logging into the system, this might be a good place to do it.

If this article has been helpful, please consider linking to it.

Categories: Linux Tags: ,

Related Posts

  1. mlissner
    December 9th, 2007 at 14:39 | #1

    Yopu might add that motd stands for Message Of The Day.

    On a similar note, you can put messages in your ~/.bashrc file with echo “message text”, and those will get displayed. However, it’s paramount that you not do this because it will break ssh!

  2. sam
    December 9th, 2007 at 14:46 | #2

    why not just do this:
    ssh myserver 2>/dev/null

  3. December 9th, 2007 at 17:44 | #3

    well your *almost* correct with the Message of the Day ( /etc/motd ) information,

    when you login you are correct that the information is displayed from /etc/motd BUT you shouldent edit that file directly without also editing /etc/motd.tail ( a skeleton without the boot-time and kernel version at the top ) otherwise on next reboot your /etc/motd message will be overridden by /etc/motd.tail

    just FYI :)

  4. December 9th, 2007 at 19:19 | #4

    Do you know if it’s possible to put dynamic information in the motd ? I’d love to put the IPAddress in there. This would be beneficial to local console users (think VMWare images)… But it could change at each boot up – think DHCP… Any ideas ?

  5. Yorokobi
    December 10th, 2007 at 14:03 | #5

    Another option:

    Create an empty /etc/issues.net file (`touch /etc/issues.net`) then uncomment the Banner line in /etc/ssh/sshd_config and restart ssh (`/etc/init.d/ssh restart`). This will trim the login [banner|notice|motd] down to one line: an OS identifier. I tested this on Dapper, haven’t tried it on Feisty or Gutsy.

  6. December 12th, 2007 at 17:31 | #6

    My preferred method for handling /etc/motd is to display the server name you just connected to. A very handy reminder, and lots of fun.

    apt-get install figlet
    figlet $HOSTNAME > /etc/motd

    FYI, the figfonts package contains some really fun fonts to use as well.

  7. Rajveer Vashisth
    January 25th, 2008 at 05:24 | #7

    Either you can use the following

    ex:
    ssh “df -k | grep -i tmp” 2>/dev/null

  8. Stefan Schnyder
    March 30th, 2009 at 08:39 | #8

    I wanted to do this myself but creating the .hushlogin file also stops printing the motd file. I like to have my motd message but not the last login info.

    I found another solution for Debian. I didn’t test it under Ubuntu but since it’s also Debian based it might work:

    Edit the file /etc/pam.d/login

    Comment out the line:
    session optional pam_lastlog.so
    which prints the last login info upon succesful login so it looks like this:
    #session optional pam_lastlog.so

    This will disable the last login message but still display the content of motd.

    Have fun! ;)

    Credits go to this guy: http://linux.derkeiler.com/Newsgroups/comp.os.linux.misc/2007-09/msg00952.html

  9. Chris
    July 24th, 2010 at 13:00 | #9

    Many thanks for the tip! It saved my day with sshfs, which fails to mount a remote partition (it gives a “read: Connection reset by peer” error message) when ssh-ing into the remote host generates output (such as a motd or some error message from the login script). Simply creating the $HOME/.hushlogin on my account on the remote host solved the problem.

    I note that the solutions proposed in the comments above probably would not solve my problem. Redirecting the ssh output is probably not an option when ssh is called via sshfs, and i cannot modify files in /etc because i do not have root privileges on the remote host.