When you connect to a remote SSH server, you're often greeted with various messages before the command prompt appears. These messages can include a welcome message, a login message, or the MOTD (Message Of The Day). While these messages may provide useful information, they can also be unnecessary if you prefer to go straight to the command prompt.

To control these messages, you can configure the server's SSHd settings. This allows you to suppress or customize the banner and MOTD displayed during login. Adjusting these settings is a straightforward way to streamline your login process or display specific information to users.

The configuration process involves editing the SSHd configuration file. This file dictates how the server handles login messages. By modifying it, you can disable unwanted messages or create custom ones that better suit your needs.

Steps to customize or disable SSH login messages:

  1. Launch terminal.
  2. Open the SSHd configuration file.
    $ sudo vi /etc/ssh/sshd_config
    [sudo] password for user:
  3. Find the Banner directive and set it to none to disable the login banner.
    Banner none

    Add the line if it doesn't already exist and remove # at the beginning of the line if it exists.

    Set the value to the path of a file and add your text to create a custom banner message to the file.

  4. Locate the PrintMotd directive and set it to no to disable the MOTD.
    PrintMotd no

    Add the line if it doesn't already exist and remove # at the beginning of the line if it exists.

    Set the value to yes and change the /etc/motd file for custom Message Of The Day.

  5. Disable the execution of motd scripts by removing execute permissions from files in the /etc/update-motd.d directory.
    $ sudo chmod -x /etc/update-motd.d/*

    Selectively disable existing scripts or add your own to create a custom message.

  6. Restart the SSHd service to apply the changes.
    $ sudo systemctl restart ssh
Discuss the article:

Comment anonymously. Login not required.