206.3. Notify users on system-related issues
Weight: 1
Description: Candidates should be able to notify the users about current issues related to the system.
Key Knowledge Areas:
    ​Automate communication with users through logon messages
    Inform active users of system maintenance
Terms and Utilities:
    /etc/issue
    /etc/issue.net
    /etc/motd
    wall
    /sbin/shutdown
    systemctl
    This lesson is all about the ways we can notifying other users. An unplanned hardware maintenance might be required, system might need to be rebooted, new kernel has been compiled , ...
There are some active and passive ways in linux, to notify other users. By considering this fact that some users might be logged off the story is made more complicated. Lets start with the simplest command.

wall

wall displays a message, or the contents of a file, or otherwise its standard input, on the terminals of all currently logged in users.(we are using CentOS7):
1
[[email protected] ~]# cat message.txt
2
Hello! This is from message.txt!
3
[[email protected] ~]# cat message.txt | wall
5
Broadcast message from [email protected] (Tue Feb 6 02:17:35 2018):
6
7
Hello! This is from message.txt!
8
logout
9
10
[email protected] ~]$ echo " This is using echo" | wall
11
12
Broadcast message from [email protected] (Tue Feb 6 02:23:30 2018):
13
14
This is using echo
Copied!
and from another user terminal point of view, what he/she sees:
1
[[email protected] ~]$ whoami
2
user1
4
Broadcast message from [email protected] (Tue Feb 6 02:17:35 2018):
5
6
Hello! This is from message.txt!
7
8
Broadcast message from [email protected] (Tue Feb 6 02:23:30 2018):
9
10
This is using echo
Copied!
How about other users users who access our server via ssh?

shh login banner message

One of the ways to protect and secure SSH logins is by displaying warming message to UN-authorized users or display welcome or informational messages to authorized users.
1
#####
2
#######
3
@ ##O#O##
4
###### @@# #VVVVV#
5
## # ## VVV ##
6
## @@@ ### #### ### ### ##### ###### # ##
7
## @ @# ### ## ## ## ### ## # ##
8
## @ @# ## ## ## ## ### # ###
9
## @@# ## ## ## ## ### QQ# ##Q
10
## # @@# ## ## ## ## ## ## QQQQQQ# #QQQQQQ
11
## ## @@# # ## ## ### ### ## ## QQQQQQQ# #QQQQQQQ
12
############ ### #### #### #### ### ##### ###### QQQQQ#######QQQQQ
Copied!
As a system adminitrator it is a good habit to configure a security banners for ssh logins. The banner contains some security warning information or general information.
1
###############################################################
2
# Authorized access only! #
3
# Disconnect IMMEDIATELY if you are not an authorized user!!! #
4
# All actions Will be monitored and recorded #
5
###############################################################
Copied!
There are two way to display messages one is using issue.net file and second one is using MOTD file.
    issue.net : Display a banner message before the password login prompt.
    motd : Display a banner message after the user has logged in.

Display SSH Warning Message to Users Before Login [/etc/issue.net] :

To display Welcome or Warning message for SSH users before login. We use issue.net file so :
1
[[email protected] ~]# find /etc/ -name issue.net
2
/etc/issue.net
3
[[email protected] ~]# cat /etc/issue.net
4
\S
5
Kernel \r on an \m
6
7
[[email protected] ~]# echo "This is from /etc/issue.net" >> /etc/issue.net
8
[[email protected] ~]# cat /etc/issue.net
9
\S
10
Kernel \r on an \m
11
This is from /etc/issue.net
Copied!
Now inside /etc/ssh/sshd_config file, We need to edit Banner /some/path like this:
1
Banner /etc/issue.net
Copied!
Our last job is to restart the SSH daemon to reflect new changes (based on your distro sysv, upstart,systemd):
1
[[email protected] ~]# systemctl restart sshd.service
Copied!
To see the result lets try to ssh to server1 from server2:
2
The authenticity of host '192.168.10.132 (192.168.10.132)' can't be established.
3
ECDSA key fingerprint is SHA256:QtfM2iXh5pxZeFdAUXEBEnRXNSP40MWIhnSYvpOBMoY.
4
Are you sure you want to continue connecting (yes/no)? yes
5
Warning: Permanently added '192.168.10.132' (ECDSA) to the list of known hosts.
6
\S
7
Kernel \r on an \m
8
This is from /etc/issue.net
9
[email protected]'s password:
Copied!

Display SSH Warning Message to Users After Login [/etc/motd] :

To display banner messages after user login, we use motd file:
1
[[email protected] ~]# find /etc/ -name motd
2
/etc/motd
3
[[email protected] ~]# cat /etc/motd
4
[[email protected] ~]# echo "This is from /etc/motd" > /etc/motd
5
[[email protected] ~]# cat /etc/motd
6
This is from /etc/motd
Copied!
again let get connected to server1 from server2:
1
[email protected]'s password:
2
Connection to 192.168.10.132 closed by remote host.
3
Connection to 192.168.10.132 closed.
5
\S
6
Kernel \r on an \m
7
This is from /etc/issue.net
8
[email protected]'s password:
9
Last login: Tue Feb 6 06:16:00 2018
10
This is from /etc/motd
Copied!
and we are done!

shutdown

shutdown schedules a time for the system to be powered down. It may be used to halt, power-off or reboot the machine.
shutdown command examples
Description
shutdown
shutdown now
shutdown 10:10
“hh:mm” for hour/minutes
shutdown -p now
poweroff the machine
shutdown -H now
halt the machine
shutdown -r10:10
reboot the machine at 10:10AM
shutdown -c
Cancel the pending shutdown
and we can send message while we are using shutdown :
1
[email protected] etc]# shutdown +15 "we goes down after 15 min"
2
Shutdown scheduled for Tue 2018-02-06 07:52:33 EST, use 'shutdown -c' to cancel.
4
Broadcast message from [email protected] (Tue 2018-02-06 07:37:33 EST):
5
6
we goes down after 15 min
7
The system is going down for power-off at Tue 2018-02-06 07:52:33 EST!
Copied!
what other users see:
1
Broadcast message from [email protected] (Tue 2018-02-06 07:37:33 EST):
2
3
we goes down after 15 min
4
The system is going down for power-off at Tue 2018-02-06 07:52:33 EST!
Copied!
that's all .

Congratulation we have done lpic2-201 !!!

Last modified 2yr ago