I'm trying to make a simple message that says something to the effect of

Server will be going down at 11:00pm UTC, March 1st, for updates.

to all users who ssh into my Raspberry Pi server (running Raspbian).

I'm not looking to add a banner, but is there a way to make a simple message appear for all users upon login until a set time or reboot? If so can I make the server run a shell script automatically at that set time?

  • 3
    Why would this not be a banner? Sounds like exactly what the ssh banner system is for. Is there any reason you don't want to use that? You can always remove it again after rebooting.
    – terdon
    Feb 22, 2020 at 17:45
  • @terdon Can you make banners automatically disappear after a specified amount of time or after reboot? Feb 22, 2020 at 17:49
  • Does it need to be automatic? It sounds like you will be doing some manual work anyway, so just clear /etc/motd. Alternatively, sure, you can set up a @reboot cron job to do it for you. This is exactly why banners exist. The details, however, will depend on your operating system, which you haven't mentioned.
    – terdon
    Feb 22, 2020 at 17:55
  • Yes. You can make it automatically disappear (using cron: at a time, or at reboot, with command at ). See man at for details. Unixes power comes form many small tools working together. Don't expect ssh to do this for you. Feb 22, 2020 at 18:04
  • @terdon The server's is running Raspbian (Based on Debian), how would I set up the @reboot cron job? Feb 22, 2020 at 18:15

2 Answers 2


The way to display messages to users who log onto your server is precisely via ssh banners. These are usually stored in /etc/motd. So, since you want to automate it, you can do the following:

  1. Make a copy of the existing file

    sudo cp /etc/motd /etc/motd.orig
  2. Manually edit the file and add your banner or, if you want this automated as well, do something like this:

    echo "Server will be going down at 11:00pm UTC, March 1st, for updates." | 
        sudo tee -a /etc/motd

    That will append your message to whatever is currently in the file.

  3. Set up a cronjob that will restore the original file on reboot.

    echo '@reboot root cp /etc/motd.orig /etc/motd' | sudo tee -a /etc/crontab

That's it. Anyone who logs in via ssh will now see your message and the message will go away on reboot.

BUT: this isn't a very good idea. For one thing, you will need to remember to remove the @reboot crontjob after you've rebooted because otherwise, it will run on every reboot from now on. Also, the whole thing doesn't make much sense. The banner system is designed to be manually edited since it's a way for the sysadmin to pass messages to users. Since you will be taking the server down manually, applying your updates or whatever maintenance you need manually and rebooting manually, I don't understand why you would bother automating the removal of the banner. Just add it, do your thing and remove it when it is no longer relevant.

  • Strictly speaking, the Message Of The Day is not what OpenSSH doco names a banner. Banners are printed before login. The Message Of The Day is printed afterwards. OpenSSH doco just calls it the "Motd".
    – JdeBP
    Feb 22, 2020 at 19:07
  • @JdeBP fair enough, yes. I just wanted to use the word the OP had used to make it very clear that this is the system they're after.
    – terdon
    Feb 22, 2020 at 19:20
  • @terdon As a side note, if I wanted to simply do an apt update and list the number of available packages updates on ssh login, how would you do that? Feb 22, 2020 at 19:44
  • @UltraGamer I'd probably have a cronjob that would run the command and store its output in a file and then add that file's contents to /etc/motd but I'm pretty sure there are other ways. Some systems do this automatically, Ubuntu for example, so have a look at how it does it or just ask a new question.
    – terdon
    Feb 22, 2020 at 21:34

This is exactly what the Message Of The Day system has always been for. Indeed, a "machine will be down on Saturday" warning to users is even the example in the NetBSD and OpenBSD manuals.

Place the warning in your motd file, conventionally /etc/motd. Remove it when you restart for maintenance. Some operating systems over-egg this pudding somewhat, providing complex ways of auto-generating messages that are in some cases more properly parts of the login banner, but even with them the /etc/motd file is a simple hand-edited file.

In general, the motd is the daily message from you the administrator to users as they log on.

Further reading

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .