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.

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

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

Append the following:

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

How to display message before OpenSSH authentication

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

Posted by Contributor