Software Engineer's Blog

How to Set an SSH Login Banner on Ubuntu 24.04

How to Set an SSH Login Banner on Ubuntu 24.04

An SSH login banner is the block of text shown before the password prompt — the “Authorized use only” notice you’ve seen when connecting to a server. On Ubuntu 24.04 it’s two files and a restart. Here’s the setup, plus the one check that keeps a typo in sshd_config from locking you out of a remote box.

The benefits of SSH Login Banner

  • Legal Notice: Warns unauthorized users and may help with legal defense.
  • Security Deterrent: Reminds users that activity is logged and monitored.
  • Environment Clarity: Helps clearly label dev/staging/prod servers to avoid mistakes.
  • Attack Surface Reduction: Prevents exposing OS/version info (which /etc/issue might leak).

Step 1. Create or Edit the Banner File

Start by creating or editing the banner file that will be displayed before the SSH login prompt. The standard location is /etc/issue.net.

$ sudo vim /etc/issue.net

Sample Banner Text

 ######################################################################
 #  WARNING: Authorized Use Only                                      #
 #                                                                    #
 #  This system is for the use of authorized users only. Unauthorized #
 #  access or use may be monitored and recorded by system personnel.  #
 #                                                                    #
 #  During routine monitoring or maintenance, authorized user         #
 #  activity may also be subject to review.                           #
 #                                                                    #
 #  By continuing, you consent to such monitoring. Evidence of        #
 #  misuse or criminal activity may be reported to law enforcement.   #
 ######################################################################

🔒 Tip: Customize the message based on your organization’s security policies or legal requirements.

Step 2. Update the SSH Configuration

Next, update the SSH daemon configuration to reference the banner file.

$ sudo vim /etc/ssh/sshd_config

Find and update the following lines:

#Banner none
Banner /etc/issue.net

Ensure that the path is an absolute path and the file exists.

Step 3. Test, then Restart the SSH Service

Before restarting, validate the config. A syntax error in sshd_config can stop the daemon from coming back up — and if you’re doing this over SSH, that means locking yourself out:

$ sudo sshd -t

No output means the config is valid. Only then apply the change:

$ sudo systemctl restart ssh

Your existing session stays connected across the restart, so open a second SSH session to confirm the banner appears and login still works before you close the first one.

File PathDescription
/etc/issueBanner shown before local console login
/etc/issue.netBanner shown before SSH login
/etc/motdMessage of the Day shown after login

⚠️ Note: The SSH Banner message is not displayed during SFTP logins.

One thing a banner doesn’t do: hide which SSH version you’re running. That version string is advertised in the protocol handshake, separate from this login banner, so a warning notice is a deterrent and a legal notice — not a security control on its own. Pair it with real hardening: key-only authentication, and a firewall that only exposes what it must (see opening ports with UFW).