Log inSign up

Change the message shown after an SSH login

On Ubuntu the login text is built by the scripts in /etc/update-motd.d/: switch one off with sudo chmod -x and add your own executable script to show live details. On Debian the same folder holds a small uname script, and the fixed text lives in /etc/motd. On Rocky Linux and AlmaLinux edit /etc/motd or drop files into /etc/motd.d/. Log in again to see the result.

Topic: Server basics · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

What is the MOTD and where does it come from?

The message of the day is the text printed after a successful login, before your prompt appears. On Ubuntu and Debian it is assembled by the PAM module pam_motd, which runs at each SSH login; on Rocky Linux and AlmaLinux the static file and the drop-in folder are shown the same way. Look at how your system is wired:

grep -n motd /etc/pam.d/sshd /etc/pam.d/login
grep -rn -i "printmotd\|printlastlog" /etc/ssh/sshd_config /etc/ssh/sshd_config.d/
ls -l /etc/update-motd.d/ /etc/motd /etc/motd.d/ 2>/dev/null

Ubuntu and Debian set PrintMotd no in the SSH daemon config because PAM already prints the message; turning it on as well would show it twice. The "Last login" line comes from a separate SSH option, PrintLastLog.

What do the Ubuntu update-motd.d scripts do?

Each file in /etc/update-motd.d/ is a small program; the numbers in the names set the order, and all executable ones run as root at login. Their combined output is cached in /run/motd.dynamic. A typical Ubuntu 24.04 server has scripts along these lines:

  • 00-header prints the welcome line with release and kernel.
  • 10-help-text adds documentation links.
  • 50-motd-news shows short news items fetched from the internet.
  • 50-landscape-sysinfo prints load, disk, memory and IP details when the landscape-common package is installed.
  • 90-updates-available and 91-release-upgrade announce pending updates and new releases.
  • 98-reboot-required warns when a restart is pending.

Preview the output without logging out:

sudo run-parts --lsbsysinit /etc/update-motd.d/

How do I remove parts of the Ubuntu message?

Remove the execute bit from the scripts you do not want; this is reversible and survives package updates better than deleting files:

sudo chmod -x /etc/update-motd.d/10-help-text
sudo chmod -x /etc/update-motd.d/50-motd-news
ls -l /etc/update-motd.d/

The news script also has its own switch. Set ENABLED=0 in /etc/default/motd-news to stop it from fetching anything:

sudo sed -i "s/^ENABLED=1/ENABLED=0/" /etc/default/motd-news
systemctl list-timers motd-news.timer

Keep 90-updates-available and 98-reboot-required executable; they are the most useful lines on a server, reminding every admin who logs in that patches or a restart are waiting.

How do I edit the message on Debian?

Debian keeps it simple: /etc/update-motd.d/10-uname prints the kernel line and /etc/motd holds a fixed paragraph about free software and warranty. Replace that paragraph with your own text:

sudo cp /etc/motd /etc/motd.orig
sudo nano /etc/motd

Any text works, for example the server role, the owner contact and a reminder of where configuration lives. Remove the uname line with sudo chmod -x /etc/update-motd.d/10-uname if you prefer a shorter greeting. Scripts you add to /etc/update-motd.d/ run on Debian exactly as they do on Ubuntu, so the status script below works on both.

How do I edit the message on Rocky Linux and AlmaLinux?

Write fixed text into /etc/motd, or place separate snippets in /etc/motd.d/, which keeps your text apart from files added by packages:

echo "app01.example.net: production web server, ask deploy before changes" | sudo tee /etc/motd.d/10-role
ls -l /etc/motd.d/

Some packages add their own lines. If the web console package is installed, for example, a file in /etc/motd.d/ advertises it; remove that symlink if you do not use the web console. There is no update-motd.d mechanism here, so dynamic content needs a different route: a login script in /etc/profile.d/, shown further down, runs for every interactive login shell.

How do I add a live status script?

Create an executable script that prints a few facts. On Ubuntu and Debian place it in /etc/update-motd.d/:

sudo tee /etc/update-motd.d/60-server-status >/dev/null <<"EOF"
#!/bin/sh
printf "\n  Host:    %s\n" "$(hostname -f)"
printf "  Uptime:  %s\n" "$(uptime -p)"
printf "  Load:    %s\n" "$(cut -d" " -f1-3 /proc/loadavg)"
printf "  Disk /:  %s used\n" "$(df -h / | awk "NR==2 {print \$5}")"
printf "  Memory:  %s available\n" "$(free -h | awk "/Mem:/ {print \$7}")"
printf "  Failed:  %s units\n\n" "$(systemctl --failed --no-legend | wc -l)"
EOF
sudo chmod +x /etc/update-motd.d/60-server-status
sudo run-parts --lsbsysinit /etc/update-motd.d/

The quoted "EOF" stops the shell from expanding anything while writing the file. Keep scripts fast; every SSH login waits for them, and a slow network call here makes the whole server feel sluggish. On Rocky and Alma save the same commands as /etc/profile.d/zz-status.sh (no shebang needed, mode 644); they then run in each user login shell rather than as root.

How do I show a banner before login?

A pre-login banner is shown by the SSH server before authentication, often used for a legal notice. Write the text and point the Banner option at it with a drop-in file:

echo "Authorized access only. Activity is logged." | sudo tee /etc/issue.net
echo "Banner /etc/issue.net" | sudo tee /etc/ssh/sshd_config.d/10-banner.conf
sudo sshd -t
# Ubuntu and Debian
sudo systemctl reload ssh
# Rocky Linux and AlmaLinux
sudo systemctl reload sshd

sshd -t checks the syntax before reloading, so a typo cannot stop the daemon. Keep the banner short and free of details such as software versions or hostnames, because anyone who connects sees it before they log in. The advanced OpenSSH guide covers other daemon settings.

How do I hide the message or troubleshoot it?

A single user can silence the message without changing it for anyone else by creating an empty file in the home directory:

touch ~/.hushlogin

If your changes do not appear, check these points in order:

  • Open a brand new SSH session; an existing session never refreshes the MOTD.
  • Confirm the script is executable with ls -l; run-parts skips anything without the execute bit and, with --lsbsysinit, names containing dots.
  • Run the script by hand to see errors: sudo /etc/update-motd.d/60-server-status.
  • Make sure ~/.hushlogin does not exist for your account.

A login message is also a natural place to point to your own runbook. Combined with SSH login alerts, it helps everyone who shares a server know what it does and who to ask.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A1-1any size works for a login message1 vCPU, 1 GB RAM, 25 GB NVMe$3.60/mo$43.20 for 12 months

Questions about Customise the login message (MOTD)

Why do I see the MOTD twice?

Both PAM and the SSH daemon print it. On Ubuntu and Debian keep PrintMotd no in the SSH config, since PAM already shows the message.

Can I use colours in the message?

Yes. Scripts can print ANSI escape codes with printf. Keep them modest, because some terminals and log viewers show raw codes.

Does the MOTD show for SFTP or scp sessions?

No. It appears only for interactive shell logins. File transfer sessions skip it, which keeps scripts and clients from breaking.

How do I restore the default Ubuntu message?

Make the scripts executable again with sudo chmod +x /etc/update-motd.d/* and set ENABLED=1 in /etc/default/motd-news.

Is it safe to put the IP address in the message?

Yes, it is only shown after login. Avoid secrets, passwords or tokens, since every user with shell access sees the text.