Mastering Linux Security and Hardening
上QQ阅读APP看书,第一时间看更新

Using the motd file

The /etc/motd file will present a message banner to anyone who logs in to a system through Secure Shell. On your CentOS machine, an empty motd file is already there. On your Ubuntu machine, the motd file isn't there, but it's a simple matter to create one. Either way, open the file in your text editor and create your message. Save the file and test it by remotely logging in through Secure Shell. You should see something like this:

 maggie@192.168.0.100's password:
Last login: Sat Oct 7 20:51:09 2017
Warning: Authorized Users Only!
All others will be prosecuted.
[maggie@localhost ~]$
motd stands for Message of the Day.

Ubuntu comes with a dynamic MOTD system that displays messages from Ubuntu's parent company and messages about the operating system. When you create a new motd file in the /etc directory, whatever message you put in it will show up at the end of the dynamic output, like so:

Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-54-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

System information as of Sat Jul 13 00:21:49 UTC 2019

System load: 0.0 Processes: 89
Usage of /: 20.9% of 20.42GB Users logged in: 1
Memory usage: 14% IP address for enp0s3: 192.168.0.3
Swap usage: 0%

* MicroK8s 1.15 is out! It has already been installed on more
than 14 different distros. Guess which ones?

https://snapcraft.io/microk8s

153 packages can be updated.
25 updates are security updates.


Warning!!! Authorized users only!
Last login: Sat Jul 13 00:09:30 2019
donnie@packtpub1:~$

The Warning!!! Authorized users only! line is what I placed into the /etc/motd file.