Creating a Custom Login Message (MOTD) in Raspbian

I have an awesome OpenVPN server setup on a Raspberry Pi to help protect my privacy when I travel. I have used it a couple times, and it has worked without a hitch; until last weekend. Prior to taking a weekend trip, I fired up the Pi, started the OpenVPN server, but I didn’t test to make sure I could connect. That would have been helpful, since I left out a critical step: opening up the proper port on my router. That’s right, my OpenVPN server ran all weekend waiting for connections that could not be made, while I used my cellular data rather than the free, insecure WiFi I had available to me. This got me wondering whether I could edit the message that is displayed when logging into the Pi via ssh. The answer: yes I can, and yes you can.

Message of the Day

The message that is displayed upon logging into an interactive terminal (either locally or via ssh) is called the motd, which is short for message of the day. The process for changing the motd varies depending on which distribution you are using. Many distros, including Debian and Raspbian, have a static motd stored as a text file which you can edit. It is located at /etc/motd. To edit the file, simply open it as an administrator in a text editor, e.g.:

sudo nano /etc/motd

Now make the changes you would like, save the file, and next time you login, you will be greated by a new motd.

Example Custom MOTD

As you may have guessed, my motd is now a reminder of the steps I need to take to get my VPN ready for use:

##################################################################
########## Welcome to user@hostName: an OpenVPN server. ##########
##################################################################

 Complete the following two tasks to initialize server:

    1. Run the following script: /home/user/bin/vpn.sh

    2. Open up port 1194/UDP on the network firewall.

##################################################################

*Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

##################################################################

Getting a Bit Fancier

Have you ever logged into Ubuntu and had it tell you at login whether there were updates available? This is possible due to Ubuntu’s use of a dynamic motd. A dynamic motd allows you to display all sorts of information such as which users are currently logged on, system load, etc. To learn how to create a dynamic motd in Raspbian, check out my article here. Do you have a custom motd? What does yours display? Let me know in the comments.

comments powered by Disqus