SSH login banners and MOTD lines present welcome text, usage policies, or system information before the shell prompt appears. On busy bastion hosts, automation targets, or shared servers, trimming or tailoring these messages keeps logins concise and avoids unnecessary noise in terminal logs and screenshots.

The OpenSSH server sshd controls these messages through the main configuration file /etc/ssh/sshd_config. The Banner directive chooses a custom text file or disables banners entirely, while PrintMotd controls the static MOTD. On Ubuntu and related systems, additional dynamic MOTD fragments are assembled from executable scripts in /etc/update-motd.d, which run at each login to generate rotating system summaries.

Changing these settings affects every SSH login on the host, so configuration updates need to respect organizational policy and any legal requirements for login notices. Disabling MOTD scripts or misconfiguring /etc/ssh/sshd_config can hide important status messages or prevent sshd from starting, so keeping a recovery path such as console or out-of-band access available before applying changes is important.

Steps to customize or disable SSH login messages:

  1. Open a terminal session on the server with a user that has sudo privileges.
    $ whoami
    user
  2. Open the SSHd configuration file /etc/ssh/sshd_config in a text editor.
    $ sudo vi /etc/ssh/sshd_config
    [sudo] password for user:

    Any text editor such as vi, nano, or vim is suitable as long as it saves plain text.

  3. Configure the Banner directive to disable the login banner or point to a custom text file.
    # disable banner
    Banner none
    
    # use a custom banner file
    Banner /etc/issue.net

    Add Banner if it is missing, remove # at the start of the line to un-comment it, and ensure the referenced file exists and is readable by the sshd process.

    Place shared banner text in a root-owned file such as /etc/issue.net with read-only permissions to prevent accidental modification.

  4. Set the PrintMotd directive according to whether the static MOTD should be shown.
    # disable the static MOTD
    PrintMotd no
    
    # keep the static MOTD enabled
    PrintMotd yes

    Add or un-comment PrintMotd in /etc/ssh/sshd_config so the configured value clearly reflects the intended behavior.

    When PrintMotd is set to yes, edit /etc/motd to control the static message content presented after login.

  5. Disable dynamic MOTD scripts in /etc/update-motd.d when additional rotating login messages are not needed.
    $ sudo chmod -x /etc/update-motd.d/*

    Remove execute permission only from specific scripts instead of all files to keep useful summaries while dropping unneeded sections.

    Disabling all scripts in /etc/update-motd.d suppresses dynamic health warnings or maintenance notices that some environments rely on for operational awareness.

  6. Save the updated configuration in the editor once all required directives have been adjusted.
  7. Test the SSHd configuration syntax before restarting the service.
    $ sudo sshd -t

    No output from sshd -t indicates that the configuration syntax is valid.

    Restarting sshd with invalid configuration can terminate current sessions and prevent new SSH logins until the error is corrected locally.

  8. Restart the ssh service to apply the updated banner and MOTD settings.
    $ sudo systemctl restart ssh
  9. Verify that SSH logins now show the expected banner and MOTD behavior from a new client session.
    $ ssh user@server.example.com
    Last login: Mon Jun 10 14:21:47 2024 from 203.0.113.10
    user@server:~$

    After disabling the banner and MOTD scripts, the login sequence omits previous banner text and dynamic MOTD lines, leaving only the standard login information and shell prompt.

Discuss the article:

Comment anonymously. Login not required.