How to Display a Custom Warning Message Before SSH Login in Ubuntu

If you manage a corporate Linux server, it is a legal and security best practice to display a warning message to anyone attempting to connect via SSH. This message, often called a “login banner,” explicitly warns unauthorized users that they are accessing a private system and that their actions are being monitored. In Ubuntu, setting up this pre-login banner is a simple two-step process.

Step 1: Create the Warning Message

The SSH daemon looks for a specific file called issue.net to generate its pre-login banner. We need to edit this file to contain your custom warning.

  1. Open your terminal and SSH into your server.
  2. Open the issue file using a text editor with root privileges:
    sudo nano /etc/issue.net
  3. Delete any generic text that might already be in the file.
  4. Type your legal warning. For example:

    WARNING: This system is for authorized users only. All activities are monitored and recorded. Unauthorized access will be fully prosecuted. Disconnect immediately if you do not have explicit permission.

  5. Press Ctrl + O then Enter to save the file, and Ctrl + X to exit the editor.

Step 2: Enable the Banner in the SSH Configuration

Now that the message exists, we must instruct the SSH service to actually display it to incoming connections.

  1. Open the main SSH configuration file:
    sudo nano /etc/ssh/sshd_config
  2. Use your arrow keys to scroll down and look for a line that says #Banner none or #Banner /etc/issue.net. (The hashtag means the line is currently disabled/commented out).
  3. Remove the hashtag (#) and ensure the line points to your file exactly like this:
    Banner /etc/issue.net
  4. Save and exit the file (Ctrl + O, Enter, Ctrl + X).
  5. Finally, restart the SSH service to apply the changes:
    sudo systemctl restart ssh

You can test this immediately by opening a new terminal window and attempting to SSH into your server. Before you are even prompted for a password, your custom legal warning will be proudly displayed on the screen.

Leave a Reply

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

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.