How to configure a Custom SSH Banner in Linux

We know that Linux applications are quite flexible in configuration. Concerning SSH, we can also configure it to our liking and not only important configurations but also information-oriented ones like a banner. That’s why today you will learn how to configure a custom banner in SSH.

What is a banner and is it necessary to have a custom banner?

We know that an internet banner is a piece of advertising that is included in websites. Concerning SSH, a banner is a welcome message that is used to give the user who is just connecting to the server a welcome message.

Although it is not mandatory to have one, it can be a good idea to set up connection rules, contact information, and references when making an SSH connection.

Although it sounds simple, it adds a more professional touch to the server and allows you to set up the conditions of use immediately.

It is with this in mind that many sysadmins go to the SSH configuration and redo their settings.

Let’s go for it.

How to set up a custom banner in SSH

In this guide, it is assumed that you already have an SSH server set up and configured. So, the first thing we need to do is to open the SSH configuration file. I will use nano

sudo nano /etc/ssh/sshd_config

In this post, we are using nano but in reality you can use any text editor.

Locate the line that starts with Banner and there you will see that it has a value of none.

#Banner none

This makes SSH default to not display any banners.

Replace none with the path to the file, you want to contain the banner. For example,

Banner /etc/imaginelinuxbanner

If the line starts with #, then remove it. Save your changes and close the editor.

Now let’s create the file that we have defined to be our banner.

sudo nano /etc/imaginelinuxbanner

And add the content you want to be displayed. For example,

----------------------------------------

Welcome to the atechwtown test server!!! 


----------------------------------------

Remember, it can be any message. Save your changes and close the editor.

To apply the changes, restart the SSH server.

sudo systemctl restart sshd

To verify the changes, connect to your server again.

ssh [user]@[server]

And you will see the banner you have chosen.

Configure a Custom SSH Banner
Configure a Custom SSH Banner

Revert changes

If you regret the changes and want to remove the banner, you have to edit the SSH configuration file again

sudo nano /etc/ssh/sshd_config

And comment out the line concerning the banner.

#Banner /etc/imaginelinuxbanner

This will deselect the banner. Save the changes and close the editor. To complete the process, restart the service.

sudo systemctl restart sshd

Conclusion

Having an SSH banner allows us to further customize our system. This can be interesting to apply to notify certain information to users who connect via SSH to the server.

I hope you liked this trick and help us to share it.

1 thought on “How to configure a Custom SSH Banner in Linux”

  1. This article is worthy of recognition and comment. I found this material attention-grabbing and engrossing. This is well-scripted and highly informative. These views appeal to me. This is how real writing is done. Thank you. Visit Us: https://www.ezeelogin.com

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top