CentOS Misc

Customizing motd


You can have the MOTD (message of the day) display messages that may be unique to the machine. One way to do this is to create a script that runs when a user logs on to the system.

First, create a script, make it executable, and save it in /etc/profile.d. Here is an example script named welcome.sh:


[root@localhost~]# nano -w welcome.sh

Copy below text into the file
#!/bin/bash
#
echo -e "
##################################
#
# Welcome to `hostname`
# This system is running `cat /etc/redhat-release`
# kernel is `uname -r`
#
# You are logged in as `whoami`
#
##################################
"

Now you need to make it executable.

[root@localhost~]# chmod +x welcome.sh

Next, edit /etc/ssh/sshd_config as follows:

[root@localhost~]# nano -w /etc/ssh/sshd_config

!uncomment below line!
PrintMotd Yes

This will allow MOTD. Now restart the sshd service.


[root@localhost~]# /etc/init.d/sshd restart

That's it! When you log in, you'd see something similar to:


##################################
#
# Welcome to srvcentos-test
# This system is running CentOS release 6.4 (Final)
# kernel is 2.6.32-358.18.1.el6.x86_64
#
# You are logged in as root
#
##################################
Note: Please note that this does not work if your login shell is (t)csh.


Customizing ssh banner message


You can also create customized greetings for users connecting to your system through ssh. Note that this message is displayed before the actual login.

Create a text file that should appear as the greetings, for example, /etc/sshgreetings.txt.



[root@localhost~]# nano -w /etc/sshgreetings.txt

Copy below text into the file
$ cat /etc/sshgreetings.txt
###############################
#
# Welcome to srvcentos-test
#
###############################
Then edit /etc/ssh/sshd_config as follows:


[root@localhost~]# nano -w /etc/ssh/sshd_config

!uncomment below line!
Banner /etc/sshgreetings.txt

IT Nyheder
RMUS 2005-2017