natjohan's blog

Posted mar. 19 mars 2013

Tip of the week 13

Display a pre and after login message in your terminal

pre login message

With the file /etc/issue, you can personnalize the displayed message at your tty connection, just edit this file as root, exit your tty and reopen, tadaaaa :

################################################################################
# Warning ! This is a restricted area, access is reserved for authorized users #
# Unauthorized access may involve prosecution                                  #
# Disconnect IMMEDIATELY if you are not an authorized user!                    #
################################################################################

user :



Note : Obviously, for security reasons, you shouldn't put sensitive informations in this file (like OS version, password, etc), because you can show it even if you are not logged in

You can can put escape sequence in your banner, you should find the different sequences with a man agetty (agetty usually analyze this file in many distros)

 The issue-file (/etc/issue or the file set with the -f option) may contain certain escape codes to display the system name, date and time etc. All escape codes consist of a backslash (\) immediately followed by one of the letters explained below.

b      Insert the baudrate of the current line.
d      Insert the current date.
s      Insert the system name, the name of the operating system. Same as `uname -s'.
l      Insert the name of the current tty line.
m      Insert the architecture identifier of the machine. Same as `uname -m'.
n      Insert the nodename of the machine, also known as the hostname. Same as `uname -n'.
o      Insert the NIS domainname of the machine. Same as `hostname -d'.
O      Insert the DNS domainname of the machine.
r      Insert the release number of the OS. Same as `uname -r'.
t      Insert the current time.
u      Insert the number of current users logged in.
U      Insert the string "1 user" or "<n> users" where <n> is the number of current users logged in.
v      Insert the version of the OS, eg. the build-date etc.

Example: On my system, the following /etc/issue file:
       This is \n.\o (\s \m \r) \t
displays as
       This is thingol.orcan.dk (Linux i386 1.1.9) 18:29:30

pre login message and open ssh server

If you want to display a banner for your ssh server, you just have to edit the sshd configuration file located in /etc/ssh/sshd_config and add or uncomment the following line (you can choose another file of your choice like /etc/myissueforsshd)

banner /etc/issue

Then restart your open ssh server :

natjohan# service sshd restart

after login message

You can put a message for logged users with /etc/motd file also called the "Mot Of The Day".

Note : Debian has a particular way to deal with motd, you just have to edit /etc/motd.tail if you want to keep you modifications, because /etc/motd is updated at each reboot (debian wiki)

Here is an example with the linux_logo command (just install it with a yum install linux_logo in Fedora) :

natjohan# linux_logo -F "Fedora Linux 5.2\nKernel Version #V\n#U\n" > /etc/motd

Here is the result :

                                                             #####
                                                            #######
               @                                            ##O#O##
######          @@#                                           #VVVVV#
##             #                                          ##  VVV  ##
##         @@@   ### ####   ###    ###  ##### ######     #          ##
##        @  @#   ###    ##  ##     ##    ###  ##       #            ##
##       @   @#   ##     ##  ##     ##      ###         #            ###
##          @@#   ##     ##  ##     ##      ###        QQ#           ##Q
##       # @@#    ##     ##  ##     ##     ## ##     QQQQQQ#       #QQQQQQ
##      ## @@# #  ##     ##  ###   ###    ##   ##    QQQQQQQ#     #QQQQQQQ
############  ###  ####   ####   #### ### ##### ######   QQQQQ#######QQQQQ

                            Fedora Linux 5.2
                  Kernel Version 3.8.1-201.fc18.x86_64
                       Uptime 2 hours 48 minutes

If you want to know more about linux_logo command just RTFM !

Go further

  • Pimp your motd with dynmotd : a dynamic motd with colors !
  • A fancy motd example
Category: ToTW
Tags: tip linux server banner

Comments