1

I looked at other posts on here but none seemed to help. Whether I set PrintMotd to "no" or "yes" in the etc/ssh/ directory under sshd_config as long as I have a "motd" file under in etc/ it gets printed twice.

Is there a different file that I need to edit that got messed up somewhere?

3 Answers 3

4

For me it was two places causing motd to be displayed twice:

1) pam.d & 2) sshd itself

To start fixing it:

~> cd /etc/pam.d/ ~> grep -i motd *

and then editing /etc/pam.d/sshd (may differ from version to version so confirm with grep output) and hash out these two lines:

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

My /etc/ssh/sshd_config also had #PrintMotd=yes (default is yes so it was active even if it was #'d out)


In the end I set /etc/ssh/sshd_config MOTD option to PrintMotd=no (not removed the # and set to no to replace the default) and enabled the /etc/pam.d/sshd motd lines so the /etc/ssh/sshd_config option printlastlog=yes will print the last login information after the pam.d motd is displayed.

Pam will also use the options in /etc/update-motd.d/ to customise the /etc/motd as well which sshd will not do as it will simply display what is already there.

0

As a fix I commented out session optional pam_motd.so in the sshd file which is found under etc/pam.d.

If there is a more proper solution to replace mine please post it as well.

0

As @Leb pointed out, there's also a pam_motd.so entry to print the /etc/motd file, so you should pick one of either telling sshd to print it via the PrintMotd yes option, or using pam_motd.

Since pam_motd is used by default for both dynamic and static chunks of the message on Ubuntu, you're probably better off disabling the additional sshd printing of the message by setting PrintMotd no in /etc/ssh/sshd_config.

You must log in to answer this question.

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