Create Message Of The Day Startup Banner CentOS

To create a custom start-up message that displays after login, edit the message of the day file, /etc/motd. Its contents are printed to every user right after a successful console or SSH login. It is a good place for a server name, a warning notice or maintenance information.

Prerequisites

  • Root access to the server (or sudo).
  • Any text editor. This guide uses vi; see Show Line Numbers with Vi for a few vi basics.

1. Open a root session

Open a terminal session, and elevate privileges to root

Root shell prompt on server mirror in a PuTTY terminal window

2. Edit /etc/motd

from here type the following command:

vi /etc/motd

type in what you would like it do display (press i first to enter insert mode)

vi editing /etc/motd with the text Zwiegnet Mirror Server, Unauthorized Access Prohibited by Law

save and quit by using ctrl+c (or Esc) to leave insert mode, then:

:wq

The file is plain text, so anything you type is shown exactly as written. Keep it short. Long banners scroll away and people stop reading them.

3. Verify

from here close your terminal session, and re-open

New login showing Last login, then the MOTD banner text above the root prompt

as you can see, the text added to the config file has been displayed. You can also test from the server itself with ssh localhost, or just view the file with cat /etc/motd.

Newer releases: /etc/motd.d

On RHEL, AlmaLinux and Rocky Linux 8 and later, /etc/motd still works the same way. Those releases also read drop-in files from /etc/motd.d/, which is where packages such as Cockpit add their own login hint. Putting your banner in a separate file, for example /etc/motd.d/10-banner, keeps it apart from anything a package writes.

Show a warning before login instead

The MOTD only appears after a user has logged in. A legal or “authorized use only” notice is usually shown before authentication as well:

  • /etc/issue is displayed on the local console before the login prompt.
  • For SSH, put the text in /etc/issue.net, set Banner /etc/issue.net in /etc/ssh/sshd_config, and restart sshd (service sshd restart, or systemctl restart sshd on systemd releases).

Troubleshooting

  • Nothing shown over SSH: check that PrintMotd is not set to no in /etc/ssh/sshd_config.
  • Shown for some users but not others: a file named .hushlogin in a user’s home directory suppresses the MOTD for that user.
  • Banner from another tool: scripts in /etc/profile.d/ can also print text at login, so check there if you see a message that is not in /etc/motd.

to get a Hosted Linux Server, or for a Linux consultant, visit www.zwiegnet.com/go to get more information

Related guides: Show Line Numbers with Vi | Patching and Installing Updates on CentOS

Leave a Reply

Your email address will not be published. Required fields are marked *