So, here's a bit of fun. How do you change the welcome banner when you log on to Ubuntu via SSH? Well, it's not quite as straightforward as I first thought...
As root, if you nano/vi/editor of choice
/etc/motd you can see the current message of the day (motd - ta-da!) and can edit this file to your hearts content to change it. However, the caveat is that on most systems this file gets re-created when you log in as there are some other scripts that run to actually write the file on log in. So, how do you change it?
Well, it's fairly easy. Firstly,
/etc/update-motd.d and list the directory (
ls -la). You should see one or more files starting with a number. For example, I have
99-footer. What happens is, when the SSH session starts, this list gets read and anything that is readable by the server gets read and dumped into that
/etc/motd file. What I decided to do was only run what I wanted to run, that is, my own file. However, when the server gets upgraded it is quite possible that these files all get re-created so if you make changes to them they may well be lost.
If you cat the footer file you should see something that looks like:
[ -f /etc/motd.tail ] && cat /etc/motd.tail || true
As well as a bunch of comments above it. If you read the comments it does tell you what to do, but basically you want to create (or update if it already exists)
/etc/motd.tail. This file is what gets dumped into motd as the last item. You can put whatever you want in
/etc/motd.tail and as long as the
99-footer is set as executable it will append the contents of
That's it! The other thing I did was to remove read and write permissions for the
10-help-text because I didn't want them appended every time. That was simply done by running:
sudo chmod -x 00-header 10-help-text
Et voila! Now only the footer script will get run and the contents of
/etc/motd.tail will always be the last thing output in the message of the day (other than the last login, but I'll leave that for another day or see here). All that's left to do is re-connect and see your shiny new welcome banner!
If you want a great quick resource to create some ASCII art as a welcome banner check out http://patorjk.com/software/taag/.