Quick tip: Display banner/message before OpenSSH authentication

Want to display a message or banner before OpenSSH (SSHD server) authentication? Try this simple tip to show the banner or ASCII logo on your Linux or Unix system.

OpenSSH has an inbuilt configuration option called Banner. The contents of the specified file are sent to the remote user before authentication is allowed. If the Banner option is set to none then no banner is displayed when using the ssh command or client. By default, no banner is showed, and the option is disabled. It is also useful to display a legal notice if required by local law.

ADVERTISEMENTS

How to display banner/message before OpenSSH authentication

  1. Log in to remote Linux and Unix server.
  2. Edit the /etc/ssh/sshd_config file.
  3. Add/edit config option. For example: Banner /etc/ssh/my_banner
  4. Save and close the file.
  5. Make sure you create a new file called /etc/ssh/my_banner file.
  6. Reload sshd service. For instance:
    # Linux #
    sudo systemctl reload ssh.service
    # FreeBSD #
    sudo /etc/rc.d/sshd restart
    # OpenBSD #
    doas /etc/rc.d/sshd restart

Sample banner/message file for sshd

Here is my file displayed using the cat command:
$ cat /etc/ssh/my_banner
Outputs:

                                                                 #####
                                                                #######
                   #                                            ##O#O##
  ######          ###                                           #VVVVV#
    ##             #                                          ##  VVV  ##
    ##         ###    ### ####   ###    ###  ##### #####     #          ##
    ##        #  ##    ###    ##  ##     ##    ##   ##      #            ##
    ##       #   ##    ##     ##  ##     ##      ###        #            ###
    ##          ###    ##     ##  ##     ##      ###       QQ#           ##Q
    ##       # ###     ##     ##  ##     ##     ## ##    QQQQQQ#       #QQQQQQ
    ##      ## ### #   ##     ##  ###   ###    ##   ##   QQQQQQQ#     #QQQQQQQ
  ############  ###   ####   ####   #### ### ##### #####   QQQQQ#######QQQQQ

Test it

Let us try out our SSH client. It is a program for logging into a remote machine and for executing commands on a system. As you know, the ssh server and client provide secure encrypted communications between two untrusted hosts over an insecure network such as LAN or Internet.
$ ssh user@box-1
$ ssh root@server1.cyberciti.biz
$ ssh vivek@www-prod-box-2 uptime

Linux and Unix Display banner or message before OpenSSH authentication

Where can I find ASCII art?

Use your favorite search engine and type:
ASCII art
Another option is to use the figlet command to display large characters made up of ordinary screen characters. We also have toilet command, which prints text using large characters made of smaller characters. It is similar to FIGlet with additional features such as Unicode handling, color fonts, filters, and various export formats. For instance:
$ figlet nixCraft
$ toilet -f mono12 -F metal nixCraft
# Display fancy banner/message before OpenSSH #
# figlet nixCraft > /etc/ssh/my_banner

       _       ____            __ _   
 _ __ (_)_  __/ ___|_ __ __ _ / _| |_ 
| '_ \| \ \/ / |   | '__/ _` | |_| __|
| | | | |>  <| |___| | | (_| |  _| |_ 
|_| |_|_/_/\_\\____|_|  \__,_|_|  \__|

How to display message before OpenSSH authentication
See "UNIX / Linux: Display Large Colourful Text Banner On Screen" for more information.

Conclusion

It is a handy little feature to spice up your terminal experience, and it works /etc/motd too. We can display banner/message before OpenSSH auth prompt. See OpenSSH documentation for more information or use the man command:
$ man 5 sshd_config
$ man sshd

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • G.K.Naidu Sep 26, 2020 @ 3:52

    Impressive but how to do it on termux msfconsole

Leave a Reply

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

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.