SSH banner warnings are required to discourage unauthorized users from accessing your network by displaying a warning message. By default, SSH server does not display any message for unauthorized users, before they try to login. If you enable SSH banner warnings, then users will be able to view the message before they enter login information. These are generally legal consequences of gaining unauthorized access to the system. Please note, it does not prevent unauthorized access but only displays a warning. In this article, we will learn how to set SSH warning message in Linux.
How to Set SSH Warning Message in Linux
Here are the steps to set SSH warning message in Linux.
1. Configure SSH Warning Banner
Open SSH configuration file in a text editor.
$ sudo vi /etc/ssh/sshd_config
Locate Banner none directive as indicated. You need to specify the path to file that contains SSH warning.
Uncomment it and specify the file to warning message. In our case, it is /etc/warning.
Banner /etc/warning
2. Create SSH Warning Banner
Next, we need to create the actual file whose path we have mentioned above. We will create a new file using text editor.
$ sudo vim /etc/warning
Paste the banner content as shown below. Edit the text as per your requirement.
------------------------------------------------------------ ------------------------------------------------------------ Authorized access only! If you are not authorized to access or use this system, disconnect now! ------------------------------------------------------------ ------------------------------------------------------------
Save and exit the file. Restart SSH service to apply changes.
$ sudo systemctl restart sshd
3. Test SSH Warning Banner
To test our banner, try logging into our server with the following command. Replace remote server IP with your SSH server’s IP address.
$ ssh user@remote-server-ip
You will see the banner message just before password prompt.
4. Set Message of the day (MOTD)
Every time we login successfully, we see a default message, known as message of the day. Sometimes it may be a welcome message configured by OS. You can change this MOTD as per your requirement.
For this purpose, open MOTD file in text editor or create a new one if it doesn’t exist already.
$ sudo vim /etc/motd
Add the welcome message as per your requirement. Save and close the file. Restart SSH server to apply changes.
$ sudo systemctl restart sshd
In this article, we have learnt how to set SSH warning message for logins. You can customize the warning message and MOTD as per your requirement. Of course, if bots are trying to gain unauthorized access to your system, it is unlikely they will ever read it. Nevertheless, it is a good deterrent for humans trying to gain unauthorized access, especially in corporate organizations.
Also read:
How to Remove Specific Item from Array in JavaScript
Detect Mobile Device in JavaScript
How to Detect Click Outside Element in JavaScript
How to Capitalize First Letter in JavaScript
Python Run Shell Command & Get Output
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.