How to disable ssh motd welcome message on Ubuntu Linux

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?

ADVERTISEMENTS

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 support@foo.bar"
echo

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

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • jack May 29, 2017 @ 10:51

    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.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.