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:

ADVERTISEMENTS

Similar Posts