30

I tried disabling the motd.dynamic in /var/run renaming the file, but did not work because the system recreates the file.

Does anyone know disable it?

1
  • The motd file does not exist in /etc. How I do?
    – hdegenaro
    Commented Jul 28, 2016 at 15:57

7 Answers 7

50

Most answers need root access.

Any user can get a clean login(include disabling the MOTD), simply run:

touch $HOME/.hushlogin
0
22

The script files in /etc/update-motd.d generate the file /var/run/motd.dynamic which you've identified as containing your MOTD.

A simplistic way to stop generating this file would be to make all of the scripts non-executable with:

chmod -x /etc/update-motd.d/*

Note: Information taken from this answer by heemayl.

3
  • 1
    If it solved your problem would you mind accepting the answer by clicking on the little grey tick/check mark :)
    – Arronical
    Commented Jul 29, 2016 at 8:28
  • 2
    I love how this is the first thing I have to do with any new Ubuntu install - delete stuff.
    – ecnepsnai
    Commented Mar 21, 2018 at 1:23
  • @ecnepsnai "user-friendly" distributions are almost always bloated—that's what you get when trying to satisfy most of the users.
    – Ruslan
    Commented Aug 22, 2020 at 9:55
18

Another way is to comment out these lines in /etc/pam.d/login:

#session    optional    pam_motd.so motd=/run/motd.dynamic
#session    optional    pam_motd.so noupdate
15

If anyone landed here because they specifically wanted to disable the "news" (ie. ads/promotional blurbs for things like macOS Kubernetes tooling) portion of the dynamic MOTD, but don't mind the rest being there (eg. the pending updates notification), that's easy too.

At the time I wrote this, this was the ad being displayed:

 * "If you've been waiting for the perfect Kubernetes dev solution for
   macOS, the wait is over. Learn how to install Microk8s on macOS."

   https://www.techrepublic.com/article/how-to-install-microk8s-on-macos/

Just open up /etc/default/motd-news and set ENABLED=0.

7

As per Alcuin Arundel's answer, also edit /etc/pam.d/sshd and comment out the pam_motd lines to remove the messages when entering through ssh.

1

There is configuration option in sshd_config, called PrintMotd. Setting it to no does the job.

4
  • 4
    The design is so sad that the scripts are run even if SSH is set to PrintMotd no. I think pam is really the best way out, it seems the noupdate setting there should tame this, but it doesn't. Commented Aug 20, 2016 at 2:42
  • 1
    As @FlorianHeigl suggests, this doesn't work.
    – einpoklum
    Commented Jun 30, 2018 at 22:28
  • The question is about disabling motd in the ssh, which the answer really does. But from your comment nor form the florian is not clear what does not work. If you have a different problem or question, there is a button up there.
    – Jakuje
    Commented Jul 1, 2018 at 7:35
  • @Jakuje It means (also in my case, although I'm using Ubuntu 20.04 which didn't exist in 2018) that you get the exact same motd even with PrintMotd set to no. Which in my case is the default anyway.
    – Lethargos
    Commented Feb 9, 2023 at 9:57
1

I found a workaround/hack

 ssh -t IP_ADDRESS bash

-t to force tty allocation

send the bash command, as sending a command doesn't output any of the bannery business.

have fun

1
  • I love it when an answer provides me food-for-thought on some tangential issue. Not directly on this, but usable elsewhere. Thanx.
    – dave58
    Commented Aug 3, 2020 at 19:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .