For legal reasons, Some people need to display a warning banner on their Linux machine before login so that a person requires to acknowledge the contents of the banner before entering the password.
Also IT departments require and have very specific security policy which might include login banners and message of the day configuration on Linux (Centos) servers. Personally I prefer to not attaching any banners and MOTD to my Linux servers. You might asks why? My answer is simple, I know where I’m connecting to:) and why to give potential hackers information about what server they are trying to hack! Hackers don’t care about security warning information!
Setup Login Banner in CentOS 6 and CentOS 7
Follow the below steps to setup the login banner in CentOS 6 and CentOS 7.
1. Create a /etc/mybanner file and fill it with your desired message as below.
# vi /etc/mybanner
Add your message in this file:
1. Unauthorized access to this machine is prohibited. 2. Only authorized System Administrator can access to this system. 3. Press exit from terminal if you are not an authorized user.
Save and close the file.
2. Edit /etc/ssh/sshd_config, to look like this Banner /etc/mybanner.
113 114 115 # default banner path 116 Banner /etc/mybanner 117 118
3. Restart sshd service sshd restart
# service sshd restart
4. Test your session.
login as: root 1. Unauthorized access to this machine is prohibited. 2. Only authorized System Administrator can access to this system. 3. Press exit from terminal if you are not an authorized user. [email protected]'s password: