Updated: 10 November 2026 · Applies to: Ubuntu 24.04 (OpenSSH 9.6p1), Debian 13 (OpenSSH 10.0p2), AlmaLinux 10.2 (OpenSSH 9.9p1); AlmaLinux 9.8 (OpenSSH config checked)
Linux can show two kinds of SSH welcome message. The message of the day (MOTD) appears after a user has logged in: put your text in /etc/motd. A pre-login banner appears before the password or key is checked, which suits a legal notice: put the text in /etc/issue.net and add Banner /etc/issue.net to the SSH server configuration.
Option 1: message after login (/etc/motd)
- Log in as root (or use
sudo) and write your text to/etc/motd, for example:Welcome to web01. Maintenance window: Sundays 02:00 to 03:00 UTC.
- Log out and log in again. No restart is needed: the file is read at every login.
On all three systems we tested, PrintMotd no is set in the SSH configuration (Ubuntu and Debian in /etc/ssh/sshd_config, AlmaLinux 10 in /etc/ssh/sshd_config.d/50-redhat.conf). That is normal: the PAM module pam_motd prints the message instead, so do not switch PrintMotd on or users see it twice. You can check that PAM is set up for it:
grep motd /etc/pam.d/sshd
Output on Ubuntu 24.04:
session optional pam_motd.so motd=/run/motd.dynamic session optional pam_motd.so noupdate
On AlmaLinux and Rocky Linux you can also drop extra text files into /etc/motd.d/, for example /etc/motd.d/backup. According to the pam_motd manual, files there are shown in name order after /etc/motd, which lets different tools or teams keep their own message without editing one shared file.
Option 2: dynamic message on Ubuntu and Debian (update-motd.d)
Ubuntu builds part of the login message from scripts. According to the Ubuntu manual, executable scripts in /etc/update-motd.d/ "are executed by pam_motd as the root user at each login", in name order, and their output goes to /run/motd.dynamic. Debian 13 has the same folder (with a 10-uname script) and the same pam_motd lines.
- Create a script, for example
/etc/update-motd.d/90-disk:#!/bin/sh echo df -h / | awk 'NR==2 {print "Disk / used: " $3 " of " $2 " (" $5 ")"}' - Make it executable:
chmod +x /etc/update-motd.d/90-disk
- To switch off a part you do not want, such as the help links or the news, remove the execute bit instead of deleting the file:
chmod -x /etc/update-motd.d/10-help-text /etc/update-motd.d/50-motd-news
- Preview the result without logging in:
run-parts --lsbsysinit /etc/update-motd.d
Output in our Ubuntu 24.04 lab container (the kernel line shows the host it ran on):
Welcome to Ubuntu 24.04.5 LTS (GNU/Linux 5.14.0-503.16.1.el9_5.x86_64 x86_64) Disk / used: 32G of 48G (69%)
Keep these scripts fast. They run at every login, and a slow command (a network call, for example) delays every SSH session.
Option 3: banner before login (/etc/issue.net and Banner)
- Write the notice to
/etc/issue.net:Authorised access only. All activity is logged.
- Tell the SSH server to send it. On current releases the main file includes
/etc/ssh/sshd_config.d/*.confnear the top, so the cleanest way is a small drop-in file:echo "Banner /etc/issue.net" > /etc/ssh/sshd_config.d/10-banner.conf
According to the OpenSSH manual, "the first obtained value will be used" for each keyword, so a drop-in that sorts early wins over a later line. Where there is no
Includeline, addBanner /etc/issue.netto/etc/ssh/sshd_configitself (it contains a commented#Banner noneline you can replace). - Test the configuration before you restart. Nothing is printed when it is valid:
sshd -t
A typo stops the test with exit code 255, for example:
/etc/ssh/sshd_config.d/20-typo.conf: line 1: Bad configuration option: Banerr /etc/ssh/sshd_config.d/20-typo.conf: terminating, 1 bad configuration options
- Confirm the value the server will use:
sshd -T | grep -i ^banner
Output:
banner /etc/issue.net
- Restart the SSH server. On AlmaLinux and Rocky Linux:
systemctl restart sshd
On Ubuntu and Debian:
systemctl restart ssh
- Keep your current session open and test from a second terminal. In our test the banner appeared straight after the connection, before authentication:
Authorised access only. All activity is logged.
Some clients hide the banner: in our test the OpenSSH client did not show it with -q or -o LogLevel=ERROR. Do not put anything secret in it, since anyone who connects sees it before logging in.
Hide the message for one user
According to the OpenSSH manual, an empty ~/.hushlogin file in a user's home folder suppresses the last login time and /etc/motd when sshd prints them itself (PrintLastLog and PrintMotd on), and it never hides the Banner. On the systems above the MOTD comes from pam_motd instead, so check the result after a test login. For per-user MOTD and banner rules see How to Set or Disable the Login Banner and MOTD for Specific Users.
Related guides
- Increasing the security of your server: sshd hardening
- What Is the Default SSH Port and How to Change It Safely
Official documentation: sshd_config(5), update-motd(5).