Note: Please do not put any classified information in a banner file since banner message is displayed before entering user/password credential during ssh/scp session.
1. Create the text file that should appear as the warning. For example /etc/sshbanner.txt:
[root@server]# vi /etc/sshbanner.txt ############################################################################################################################################################### # # WARNING TO USERS OF THIS SYSTEM # # THIS IS A NOTICE OF LINUX DEPARTMENT # # HOW TO CREATE A SSH BANNER IN LINUX SERVER # ###############################################################################################################################################################
2. Add the location of your banner into configuration file /etc/ssh/sshd_config as shown below:
[root@server]# grep -i banner /etc/ssh/sshd_config # no default banner path Banner /etc/sshbanner.txt
3. Restart the SSHD Daemon:
[root@server]# /etc/init.d/sshd restart Stopping sshd: [ OK ] Starting sshd: [ OK ] [root@sserver]#
4. Try to login by ssh again to the server:
[root@server]# ssh server.ip.or.hostname ############################################################################################################################################################### # # WARNING TO USERS OF THIS SYSTEM # # THIS IS A NOTICE OF LINUX DEPARTMENT # # HOW TO CREATE A SSH BANNER IN LINUX SERVER # ############################################################################################################################################################### root@server.ip.or.hostname password: Last login: Mon Jan 25 05:44:43 2021 from server.ip.or.hostname [root@server]#