SSH servers can display login notices and MOTD (message of the day) before the shell prompt. Administrators can suppress these server-provided notices and MOTD on Linux; changes to PAM MOTD handling affect all users whose SSH sessions use that server's PAM configuration.
The OpenSSH server controls the pre-authentication banner with the Banner directive. Post-login text is split across PrintMotd, PrintLastLog, and, on Ubuntu or Debian systems that use PAM, pam_motd.so entries in /etc/pam.d/sshd.
Suppress only messages that are operational noise. Keep legal notices, access warnings, and maintenance notices enabled when policy requires them, and keep an existing SSH session or console path open until a new login reaches the prompt without the old text.
Steps to disable SSH server login banners and MOTD on Linux:
- Open a terminal on the SSH server with an account that can use sudo.
A mistake in these files can block new logins, so the current session stays your way back in until a separate test login succeeds after the reload.
- Back up the PAM SSH session file before changing MOTD handling.
$ sudo cp /etc/pam.d/sshd /etc/pam.d/sshd.bak
Ubuntu and Debian commonly print MOTD text from PAM even when OpenSSH reports PrintMotd no.
- Open an early OpenSSH server drop-in file.
$ sudoedit /etc/ssh/sshd_config.d/00-suppress-login-messages.conf
Use /etc/ssh/sshd_config instead if the server configuration does not include /etc/ssh/sshd_config.d/*.conf.
- Disable the server-side login messages in the drop-in file.
Banner none PrintMotd no PrintLastLog no
Banner none removes the pre-authentication notice. PrintMotd no and PrintLastLog no suppress MOTD and last-login output handled directly by sshd.
- Open the PAM SSH session file.
$ sudoedit /etc/pam.d/sshd
Skip this edit on hosts that do not use PAM for SSH sessions or do not contain pam_motd.so entries.
- Comment the pam_motd.so session lines.
#session optional pam_motd.so motd=/run/motd.dynamic #session optional pam_motd.so noupdate
Commenting these lines suppresses SSH MOTD output for all users who pass through /etc/pam.d/sshd. Do not remove policy-required notices.
- Test the OpenSSH server configuration.
$ sudo sshd -t
No output means the active sshd configuration parsed successfully.
- Reload the SSH service.
$ sudo systemctl reload ssh
Use sudo systemctl reload sshd on systems where the unit is named sshd. If reload is unsupported, restart only after sshd -t succeeds.
Related: How to manage the SSH server service with systemctl - Open a new SSH session from another client.
$ ssh user@host.example.net user@host:~$
The prompt should appear without the previous banner, MOTD, or last-login text. If other text still appears, check shell startup files such as /etc/profile, files under /etc/profile.d, or the user's shell profile.