Skip to content

How to Set or Disable the Login Banner and MOTD for Specific Users

Updated 3 min read

Updated: 28 September 2026 · Applies to: OpenSSH and pam_motd on AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10, Ubuntu 24.04 and 26.04, Debian 13

Linux servers can show two kinds of messages to people who log in over SSH: a banner, shown before login (often a legal warning), and the MOTD ("message of the day"), shown after login. This guide sets both and turns them off for specific users. We tested each method with real SSH logins on AlmaLinux 9 and Ubuntu 24.04.

Where the MOTD comes from

  • /etc/motd: a static text that you edit.
  • /etc/motd.d/ (AlmaLinux, Rocky Linux, RHEL): extra text files, for example the Cockpit hint.
  • /etc/update-motd.d/ (Ubuntu): scripts that build a dynamic message, such as the system information and update notices.

On current systems the MOTD is printed by the PAM module pam_motd, not by the SSH server.

Turn the MOTD off for one user

touch ~/.hushlogin

Run it as that user (or create the file in their home folder, owned by them). From the next login, the MOTD and the "Last login" line are no longer shown for this user. In our tests this worked on both AlmaLinux 9 and Ubuntu 24.04.

Show a message to one user or group only

Create /etc/profile.d/zz-notice.sh, which runs at every interactive login:

case "$(id -un)" in
  alice|bob) echo "Reminder: this server is scheduled for maintenance on Sunday." ;;
esac
if id -nG | grep -qw developers; then
  echo "Deploys go through CI only, please."
fi

A banner before login (all users or per user)

  1. Write the text to /etc/issue.net.
  2. Create /etc/ssh/sshd_config.d/20-banner.conf:
    Banner /etc/issue.net
    
    Match User backupbot
        Banner none
    The Match block turns the banner off for the account backupbot, which is useful for automated logins. PrintMotd cannot be used inside a Match block, which is why the MOTD is handled with .hushlogin instead.
  3. Check and apply:
    sshd -t
    systemctl reload sshd      # AlmaLinux, Rocky Linux, RHEL
    systemctl reload ssh       # Ubuntu, Debian

Turn off Ubuntu's dynamic MOTD parts

For the news part, set ENABLED=0 in /etc/default/motd-news; the script only runs when that file says ENABLED=1. For other parts, remove the execute permission from the script you do not want, for example chmod -x /etc/update-motd.d/10-help-text. A later update of the package that owns the script may make it executable again, so check after upgrades.

Official documentation: pam_motd manual page and sshd_config Banner.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket