How to disable ssh motd welcome message on Ubuntu Linux

Posted on in Categories , , last updated May 29, 2017

I want to disable the message of the day (motd) welcome message after I login over ssh on Ubuntu Linux. How do I disable motd on Ubuntu Linux 17.04?

The contents of /etc/motd are displayed by pam_motd after a successful login over ssh but just before it executes the login shell such as bash. You will see messages as follows on screen:
Fig.01: How to disable motd welcome message after SSH login?
Fig.01: How to disable motd welcome message after SSH login?

However, Ubuntu Linux uses update-motd which is a dynamic MOTD generation tool. From the man page:

UNIX/Linux system adminstrators often communicate important information to console and remote users by maintaining text in the file /etc/motd, which is displayed by the pam_motd(8) module on interactive shell logins.

Traditionally, this file is static text, typically installed by the distribution and only updated on release upgrades, or overwritten by the local administrator with pertinent information.

Ubuntu introduced the update-motd framework, by which the motd(5) is dynamically assembled from a collection of scripts at login.

Executable scripts in /etc/update-motd.d/* are executed by pam_motd(8) as the root user at each login, and this information is concatenated in /var/run/motd. The order of script execution is determined by the run-parts(8) –lsbsysinit option (basically alphabetical order, with a few caveats).

How do I view current scripts?

Type the following cd command:
$ cd /etc/update-motd.d/
$ ls -l

Use the cat command to view scripts:
$ cat 90-updates-available
Sample outputs:

Fig.02: Dynamic MOTD generation scripts on Ubuntu Linux
Fig.02: Dynamic MOTD generation scripts on Ubuntu Linux

How do I disable the script?

To disable all script run the following chmod command:
sudo chmod -R 0644 /etc/update-motd.d/
OR
sudo chmod -xR /etc/update-motd.d/
To disable an individual script run:
sudo chmod 0644 /etc/update-motd.d/50-motd-news
OR
sudo chmod -x /etc/update-motd.d/50-motd-news
Verify it with the ls command:
$ ls -l /etc/update-motd.d/
$ ls -l /etc/update-motd.d/50-motd-news

Sample outputs:

-rw-r--r-- 1 root root 4196 Feb 16 01:24 /etc/update-motd.d/50-motd-news

How to create my own script in /etc/update-motd.d/ directory?

Just create a shell script as follows:
$ sudo vi /etc/update-motd.d/99-my-messages
Sample script:

#!/bin/sh
echo
echo "Unauthorized access to this device is prohibited."
echo "For support call xxx-yyy-zzz or write to [email protected]"
echo

Set executable permissions:
$ chmod +x /etc/update-motd.d/99-my-messages

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

1 comment

  1. Ubuntu is actually a GNU system (based on Debian GNU/Linux) with Linux added. Calling Ubuntu “Ubuntu Linux” makes it seem that Ubuntu is a modification of Linux, the kernel, which isn’t correct since Ubuntu is more than a kernel. Linux is just a part of the system; the operating system is the GNU system. I’d recommend to call the system by its proper name: GNU/Linux.

Comments are closed.