How to Enable or Disable Login Messages

By | 2007/12/09

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.

10 thoughts on “How to Enable or Disable Login Messages

  1. mlissner

    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!

    Reply
  2. imbrandon

    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 :)

    Reply
  3. munwin

    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 ?

    Reply
  4. Yorokobi

    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.

    Reply
  5. Lonnie Olson

    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.

    Reply
  6. Rajveer Vashisth

    Either you can use the following

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

    Reply
  7. Stefan Schnyder

    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

    Reply
  8. Chris

    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.

    Reply
  9. sdebaun

    Add Dynamic (or custom) Log-in Messages or remove them – (UBUNTU 10.04 LTS)
    ——————————————————————————————————

    To add/edit dynamic info to the log-in message add a numbered script to:
    /etc/update-motd.d/

    By numbered I mean, ordered. For example 000-yourmessage will come before 999-yourmessage.

    To customize, just add what you want to the existing scripts, comment out what you don’t want, or remove the existing ones if you like.

    (Editing /etc/motd does not work. Read the comment in: /etc/update-motd.d/99-footer)

    To silence the log-in message-
    By default, simply adding .hushlogin to your user home directory removes login messages for that user. The default configuration for that is configured in:
    /etc/login.defs

    You can change the .hushlogin path if needed, possibly silencing the message for all users by doing so.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *