/etc/motd printing twice on Gentoo Linux
Solution 1
Looks like the answer was in the /etc/pam.d/login and /etc/pam.d/system-login files. I had to comment out the pam_motd.so lines.
Solution 2
I had the same issue with Ubuntu 15.04 and SSHD configured to use PAM Authentication. My server was sending two MOTD. I managed to make it work nicely by letting SSHD refreshing the MOTD at each login. This is done by editing /etc/pam.d/sshd and removing/commenting the line which says noupdate
.
# Print the message of the day upon successful login.
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
session optional pam_motd.so motd=/run/motd.dynamic
#session optional pam_motd.so noupdate
The drawback is that if the process of refreshing this message takes a while (or CPU time) logging in could waste some resource, appear to take a while or even timeout.
However, the basic default MOTD as configured out of the box in Ubuntu 15.04 should not cause trouble.
Solution 3
When I had this problem, I learned it was a combination of settings active when the system had been issued to me. The first copy of the message was printed before SSH authentication happened, and was due to SSH's Banner
option being set in sshd_config:
Banner /etc/motd
A misuse of MOTD more than a misuse of Banner
.
The second copy of the message was printed because in its default configuration, SSH prints the MOTD upon login. I disable that by setting PrintMotd
:
PrintMotd no
Solution 4
Also check out /etc/issue, some systems print both and they might just contain the same text. Note that I don't use gentoo so this might not be the case.
Solution 5
I think it would make more sense to make sure that the only component that prints MOTD is PAM. This way you can disable it everywhere else and still comply with your audit requirement.
Just my $0.02.
Alfredo Hu
I'm a software engineer that writes both application and system-level code. I've coded in a variety of languages, both compiled and interpreted. I like working with Linux, and have been using it for over 15 years. I'm also familiar with zOS, AIX, and have been known to dabble in Windows development. I'm a fan of open-source software, and have run a variety of Linux distributions over the years.
Updated on June 12, 2022Comments
-
Alfredo Hu almost 2 years
I've run into a problem where I'm getting two printouts of my /etc/motd file on Gentoo Linux. sshd is doing one of the printouts, and I can toggle that by configuring /etc/ssh/sshd_config, but I can't find out who's printing the second copy. I can't disable sshd from printing out the motd due to an audit requirement. I'm running the bash shell, for what it's worth
Any ideas who's printing the second copy? I don't think it's bash, as when I change /etc/passwd to use /bin/ksh for my shell, I still get the motd displayed.
It's not /etc/issue, as that contains the string "This is \n (\s \m \r) (\l)", which is printed only when you're sitting in front of the machine.
-
fwalch over 11 yearsI had this problem when logging in locally; one printout from PAM and one from login. In this case you could also keep the PAM config and create a
~/.hushlogin
file (seeman login
). -
Rimmel over 6 yearsMy /etc/pam.d/sshd had two lines: session optional pam_motd.so motd=/run/motd.dynamic session optional pam_motd.so noupdate I commented out the first, and it fixed the issue for me.
-
Jonathan Cross about 6 yearsThis answer was the only one listed on this page that worked for me on
Ubuntu 16.04.4 LTS
.