• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
    • Troubleshooting
  • OS
    • HPUX
    • Linux
  • Miscellaneous
    • Software & Tools
    • Cloud Services
    • System services
    • Virtualization
  • Certification Preparations
    • AWS Certified Solutions Architect – Associate
    • AWS Certified Solutions Architect – Professional
    • AWS Certified SysOps Administrator – Associate
    • AWS Certified Cloud Practitioner
    • Certified Kubernetes Administrator
    • Hashicorp Certified Terraform Associate
    • Oracle Cloud Infrastructure Foundations 2020 – Associate
  • Tips & Tricks
  • Linux commands
You are here: Home / Tips & Tricks

How to configure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora)

Published: November 10, 2017 | Modified: June 25, 2020



Learn how to create login banners in Linux to display a different warning or information message to the user who is about to log in or after he logs in.

Login banner messages in Linux

Whenever you log in to some production systems of the firm, you get to see some login messages, warnings, or info about the server you are about to log in or already logged in like below. Those are the login banners.

Login welcome messages in Linux

In this article we will walk you through how to configure them.

There are two types of banners you can configure.

  1. Banner message to display before user logs in (configure in the file of your choice eg. /etc/login.warn)
  2. Banner message to display after the user successfully logged in (configure in /etc/motd)

How to display message when user connects to system before login

This message will be displayed to the user when he connects to the server and before he logged in. This means when he enter the username, this message will be displayed before the password prompt.

You can use any filename and enter your message within. Here we used /etc/login.warn file and put our messages inside.

# cat /etc/login.warn
        !!!! Welcome to KernelTalks test server !!!!
This server is meant for testing Linux commands and tools. If you are
not associated with kerneltalks.com and not authorized please dis-connect
immediately.

Now, you need to supply this file and path to sshd daemon so that it can fetch this banner for each user login request. For that open /etc/sshd/sshd_config file and search for the line #Banner none

Here you have to edit the file and write your filename and remove the hash mark. It should look like : Banner /etc/login.warn

Save the file and restart sshd daemon. To avoid disconnecting existing connected users, use the HUP signal to restart sshd.

root@kerneltalks # ps -ef |grep -i sshd
root     14255     1  0 18:42 ?        00:00:00 /usr/sbin/sshd -D
root     19074 14255  0 18:46 ?        00:00:00 sshd: ec2-user [priv]
root     19177 19127  0 18:54 pts/0    00:00:00 grep -i sshd

root@kerneltalks # kill -HUP 14255

That’s it! Open new sessions and try login. You will be greeted with the message you configured in the above steps.

Login banner in Linux

You can see the message is displayed before the user enters his password and log in to the system.

How to display message after user logs in

Message user sees after he logs into the system successfully is Message Of The Day & is controlled by /etc/motd file. Edit this file and enter the message you want to greet the user with once he successfully logged in.

root@kerneltalks # cat /etc/motd
           W E L C O M E
Welcome to the testing environment of kerneltalks.
Feel free to use this system for testing your Linux
skills. In case of any issues reach out to admin at
info@kerneltalks.com. Thank you.

You don’t need to restart sshd daemon to take this change effect. As soon as you save the file, its content will be read and displayed by sshd daemon from the very next login request it serves.

Message Of The Day

You can see in the above screenshot: Yellow box is MOTD controlled by /etc/motd and the green box is what we saw earlier login banner.

You can use tools like cowsay, banner, figlet, lolcat to create fancy, eye-catching messages to display at login. This method works on almost all Linux distros like RedHat, Centos, Ubuntu, Fedora, etc.

⇠ Previous article
All you need to know about sosreport tool
Next article ⇢
How to change timezone in Linux server (RedHat, CentOS, Ubuntu)

Related stuff:

  • Cowsay: Fun in Linux terminal
  • Hollywood movie MATRIX like desktop in Linux terminal
  • Format date and time for Linux shell script or variable
  • Create beautiful ASCII text banners in Linux
  • 8 ways to generate random password in Linux
  • How to test internet speed in Linux terminal
  • 4 tools to download any file using the command line in Linux
  • How to change UID or GID safely in Linux
  • GitBash not prompting for MFA in AWS CLI
  • 3 tricks to get multiple commands output in the same row
  • How to save PuTTY session output automatically
  • How to get directory size in Linux

Filed Under: Tips & Tricks Tagged With: login banners, login banners in linux, ssh login banners

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Comments

  1. Ben Chapman says

    September 23, 2020 at 11:29 pm

    Thank you for this! Exactly what I needed.

    Reply
  2. Aziz says

    April 24, 2022 at 8:52 pm

    Thanks for sharing the knowledge!!

    Reply

Share Your Comments & Feedback: Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2023 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.