MOTD and Banner messages for SSH connections

There are two messages you can set in the sshd configuration. One is MOTD (message of the day) and the other one is the Banner.

Banner Message

The Banner message is displayed before the password login prompt.
To edit/set the Banner message:

1. Login to SSH.

2. We will use the system’s file /etc/issue.net for our message. Edit the file with vi /etc/issue.net . Edit the message as you wish.

3. Now we will edit the /etc/sshd_config file. Use vi /etc/ssh/sshd_config. Look for

# no default banner path
#Banner none

and modify to

# no default banner path
Banner /etc/issue.net

4. Exit the editor and restart the SSH server. In our case:

root@web [~]# service sshd restart
Redirecting to /bin/systemctl restart sshd.service
root@web [~]#

5. On next login prompt, you will see the Banner message

login as: root
This computer system is for authorized users only. Individuals using this
system without authority or in excess of their authority are subject to
having all their activities on this system monitored and recorded or
examined by any authorized person, including law enforcement, as system
personnel deem appropriate. In the course of monitoring individuals
improperly using the system or in the course of system maintenance, the
activities of authorized users may also be monitored and recorded. Any
material so recorded may be disclosed as appropriate. Anyone using this
system consents to these terms.


root@web.plothost.com's password:


MOTD Text

The MOTD is displayed after a successful login.
To edit/set MOTD follow the steps:

1. Login to SSH.

2. The MOTD text is in the file /etc/motd. So edit it with vi /etc/motd

3. Now we will enable motd in the ssh server configuration. Use vi /etc/ssh/sshd_config. Look for

#PrintMotd yes

and modify to

PrintMotd yes

4. Exit the editor and restart the SSH server. In our case:

root@web [~]# /bin/systemctl restart sshd.service
root@web [~]#

5. On the next successful login, you will see the MOTD text

login as: root
This computer system is for authorized users only. Individuals using this
system without authority or in excess of their authority are subject to
having all their activities on this system monitored and recorded or
examined by any authorized person, including law enforcement, as system
personnel deem appropriate. In the course of monitoring individuals
improperly using the system or in the course of system maintenance, the
activities of authorized users may also be monitored and recorded. Any
material so recorded may be disclosed as appropriate. Anyone using this
system consents to these terms.


root@web.plothost.com's password:
Last login: Thu Dec 12 06:57:43 2019 from 192.168.2.34
Welcome! This is the MOTD :) <------------------------
root@web [~]#


Notice that instead of the vi tool you can use the nano editor or any other editor.

Resources:
issue.net man page
How to install nano editor

Share this post: