tags:

views:

1908

answers:

6

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.

A: 

It is probably being done from the shell itself. Check the global profile and bashrc to see if this might be the case.

Nik Reiman
A: 

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.

axel_c
+4  A: 

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.

Nighthawk
A: 

Are you login from SSH connection??.. If so, maybe you must enable and set to no the key "PrintMotd No" on your sshd_config file and restart the service...

+1  A: 

In addition to commenting out the pam_motd.so lines, don't forget to also comment out the following lines in /etc/pam.d/login and /etc/pam.d/system-login:

session optional pam_lastlog.so

Like this, the "last login" line gets printed once instead of twice.

+1  A: 

I had this problem too, and what was troubling to me was not the double-motd, it was the double "Last login" lines with the second referring back to the login event just above it.

I thought it might indicate foul play of some sort, as if my login were being re-directed or piped through some spyware or something.

Here is what the bottom 5 lines of my /etc/pam.d/system-login looks like:

session         required        pam_env.so
#session        optional        pam_lastlog.so
session         include         system-auth
#session        optional        pam_motd.so motd=/etc/motd
session         optional        pam_mail.so

Note the commented-out lines. Everything works as expected now. Thanks, Daniel.