How to set custom login banner message in linux
SSH banner messages are necessary when you want to display a warning for users when they access a server over SSH.
Let’s see how to set a custom SSH warning banner.
Configure SSH Warning Banner
Specify the banner message file in /etc/ssh/sshd_config SSH configuration:
1 | $ sudo vim /etc/ssh/sshd_config |
Create the SSH Banner message file
Create a new banner message file as specified in /etc/ssh/sshd_config:
1 | $ sudo vim /etc/banner |
Verify the banner message
To apply the changes, restart the SSH service:
1 | $ sudo systemctl restart sshd |
To test out the banner, login to the system over ssh:
1 | ssh root@test-vm1 |
Setting a MOTD Banner
If you wish to set a MOTD (Message Of The Day) banner right after login, edit the /etc/motd file.
1 | $ sudo vim /etc/motd |
The MOTD will be displayed next time you log in to the system.
1 | ssh root@test-vm1 |