You can display a warning message to unauthorized users or display a welcome message or informational message to authorized users for SSH logins. These messages can be displayed through banners, a legal banner contains some security warning information or general information, that alerts the user. It can be used for security, legal info, company policy, etc.
There is two way to display messages one is using issue.net (ssh_banner) file and the second one is using MOTD file.
- ssh_banner: Display a banner message before the password login prompt.
- motd: Display a banner message after the user has logged in.
Display SSH Warning Message to Users Before Login
You can display the banner message before login through issue.net (ssh_banner) file, this message will be displayed before the password login prompt. Follow the process shown below:
- Open the master ssh configuration file etc/ssh/sshd_config to enable banners.
- Search for the word “Banner” and add the line Banner /etc/ssh_banner and save the file. Here I have created the file ssh_banner instead on issue.net.
- Now open the file /etc/ssh_banner in vi editor and add the message which you want to display, save the file.
- restart the SSH daemon to reflect new changes.
-
Now try to connect to the server, you will get the below message:
Display SSH Warning Message to Users After Login
To display banner messages after login, you need to modify motd file, which is used to display banner messages after login.
- Open the file /etc/motd in vi editor.
- Add the banner message and save the file.
- Now again try to login into the server you will get both the banner messages.