11

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?

Thank you.

  • The motd file does not exist in /etc. How I do? – hdegenaro Jul 28 '16 at 15:57
16

Most answers need root access.

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

touch $HOME/.hushlogin
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – Graham Aug 28 '18 at 16:48
  • 1
    @abu_bua: if you see something in the LQ review queue that you know nothing about, press skip or google the answer. ;-) This answer is perfectly valid as it hushes motd. – Fabby Aug 28 '18 at 19:52
  • @Graham --------^ – Fabby Aug 28 '18 at 19:53
  • @qinsi: Welcome to Ask Ubuntu! :-) Thanks for teaching me something today and sorry about ending up in the LQ queue. +1 – Fabby Aug 28 '18 at 19:55
  • 2
    @abu_bua I'm not saying it's the best of all answers. All I'm saying is: 1. It's an answer, not a question. 2. I didn't know about .hushlogin. 3. As I learned something today, I'm upvoting. 0:-) – Fabby Aug 28 '18 at 20:09
14

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.

  • 1
    If it solved your problem would you mind accepting the answer by clicking on the little grey tick/check mark :) – Arronical Jul 29 '16 at 8:28
  • 2
    I love how this is the first thing I have to do with any new Ubuntu install - delete stuff. – ecnepsnai Mar 21 '18 at 1:23
13

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
5

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.

  • 1
    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. – Florian Heigl Aug 20 '16 at 2:42
  • 1
    As @FlorianHeigl suggests, this doesn't work. – einpoklum Jun 30 '18 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 Jul 1 '18 at 7:35
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.