Monthly Archives: December 2019

MOTD and Banner messages for SSH connections

There are two messages you can set in the sshd configuration. One is MOTD (message of the day) and the other one is the Banner.

Banner Message

The Banner message is displayed before the password login prompt.
To edit/set the Banner message:

1. Login to SSH.

2. We will use the system’s file /etc/issue.net for our message. Edit the file with vi /etc/issue.net . Edit the message as you wish.

3. Now we will edit the /etc/sshd_config file. Use vi /etc/ssh/sshd_config. Look for

# no default banner path
#Banner none

and modify to

# no default banner path
Banner /etc/issue.net

4. Exit the editor and restart the SSH server. In our case:

root@web [~]# service sshd restart
Redirecting to /bin/systemctl restart sshd.service
root@web [~]#

5. On next login prompt, you will see the Banner message

login as: root
This computer system is for authorized users only. Individuals using this
system without authority or in excess of their authority are subject to
having all their activities on this system monitored and recorded or
examined by any authorized person, including law enforcement, as system
personnel deem appropriate. In the course of monitoring individuals
improperly using the system or in the course of system maintenance, the
activities of authorized users may also be monitored and recorded. Any
material so recorded may be disclosed as appropriate. Anyone using this
system consents to these terms.


root@web.plothost.com's password:


MOTD Text

The MOTD is displayed after a successful login.
To edit/set MOTD follow the steps:

1. Login to SSH.

2. The MOTD text is in the file /etc/motd. So edit it with vi /etc/motd

3. Now we will enable motd in the ssh server configuration. Use vi /etc/ssh/sshd_config. Look for

#PrintMotd yes

and modify to

PrintMotd yes

4. Exit the editor and restart the SSH server. In our case:

root@web [~]# /bin/systemctl restart sshd.service
root@web [~]#

5. On the next successful login, you will see the MOTD text

login as: root
This computer system is for authorized users only. Individuals using this
system without authority or in excess of their authority are subject to
having all their activities on this system monitored and recorded or
examined by any authorized person, including law enforcement, as system
personnel deem appropriate. In the course of monitoring individuals
improperly using the system or in the course of system maintenance, the
activities of authorized users may also be monitored and recorded. Any
material so recorded may be disclosed as appropriate. Anyone using this
system consents to these terms.


root@web.plothost.com's password:
Last login: Thu Dec 12 06:57:43 2019 from 192.168.2.34
Welcome! This is the MOTD :) <------------------------
root@web [~]#


Notice that instead of the vi tool you can use the nano editor or any other editor.

Resources:
issue.net man page
How to install nano editor

How to get OS info in Linux

Many times you may need to now the operating system information. We will discuss some useful commands. We will focus on commands that work on RedHat/CentOS installations, as these are the most used OSs in the web hosting industry.

1.1. For kernel version information, use uname -a

root@web [~]# uname -a
Linux web.plothost.com 2.6.32-042stab134.8 #1 SMP Fri Dec 7 17:16:09 MSK 2018 x86_64 x86_64 x86_64 GNU/Linux
root@web [~]#

1.2. Another command for kernel information is cat /proc/version

root@web [~]# cat /proc/version
Linux version 2.6.32-042stab134.8 (root@kbuild-rh6-x64.eng.sw.ru) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) ) #1 SMP Fri Dec 7 17:16:09 MSK 2018
root@web [~]# ^C

2.1. To get the operating system version on RedHat distributions (RedHat, CentOS etc), use cat /etc/redhat-release

root@web [~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
root@web [~]#

2.2. For other Linux distributions, use cat /etc/*-release

root@web [~]# cat /etc/*-release
CentOS Linux release 7.7.1908 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.7.1908 (Core)
CentOS Linux release 7.7.1908 (Core)
root@web [~]#

2.3. Another command here is lsb_release -a. This command will list some LSB (Linux Standard Base) information.

root@web [~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.7.1908 (Core)
Release:        7.7.1908
Codename:       Core
root@web [~]#

3. Info about the hostname, virtualization type, architecture, kernel can be shown by using hostnamectl command.

root@web [~]# hostnamectl
   Static hostname: web.plothost.com
         Icon name: computer-container
           Chassis: container
        Machine ID: 8ae4190274f046cea9ff6079c62ba82f
           Boot ID: 1ab0cef548a8424298b26d7247d3440a
    Virtualization: openvz
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 2.6.32-042stab134.8
      Architecture: x86-64
root@web [~]# 

Lookup and reverse lookup for a domain/IP on Google DNS

Google DNS servers are:
8.8.8.8 – primary server
8.8.4.4 – secondary server

You can use these two servers to check for domains/IPs instead of using the local nameservers. To check for a domain, use:

dig <domain name> @8.8.8.8 +short
root@web [~]# dig web.plothost.com @8.8.8.8 +short
162.255.200.200
root@web [~]# 

To execute a reverse lookup, use:

dig -x IP @8.8.8.8 +short
root@web [~]# dig -x 162.255.200.200 @8.8.8.8 +short
web.plothost.com.
root@web [~]#

If you changed your domain nameservers or dedicated IP, it is a good idea to flush the Google DNS cache. You can do this on Flush Google DNS Cache.

Instead of 8.8.8.8 in the above commands, you can also use 8.8.4.4

References:
Google Public DNS

Remove messages from the mail queue – Exim

Exim is a mail transfer agent (MTA) used on many Linux operating systems, especially on web hosting servers. Even if web hosting control panels like cPanel, DirectAdmin, Plesk, VestCP offers the possibility to manage the mail queue from the GUI interface, sometimes it can be faster to manage it from the command line. We will list some useful commands. For more information on these, please consult the exim command line manual.

First, you will probably want to list the messages in the queue. Use:

exim -bp
root@www [~]# exim -bp

 6h  9.7K 1iduBA-0002W9-3a <News@domain.com>
          email@gmail.com

 4h   23K 1idwSE-0005Wp-81 <>
          clubdjpr@www.plothost.com

 4h  9.0K 1idwTc-0005cJ-QN <> *** frozen ***
          b2evo-return@domain.com

 3h  156K 1idxAf-0000O8-HW <n0238a2e840-a0d3d4d86ebc44ba-brian===domain.com@bounce.twitter.com>
          brian@domain.com

 2h  8.7K 1idxkx-0003AF-1I <> *** frozen ***
          b2evo-return@domain.com

66m   13K 1idypK-0008I8-6G <> *** frozen ***
          user123@live.com

To remove a message from the queue, use:

exim -Mrm <message-id>
root@www [~]# exim -Mrm 1idypK-0008I8-6G
Message 1idypK-0008I8-6G has been removed
root@www [~]#

To remove all the messages from the queue:

root@www [~]# exim -bpru | awk '{print $3}' | xargs exim -Mrm
Message 1idkGG-0004yI-T6 has been removed
Message 1idybs-0007CS-Jz has been removed
Message 1idxkx-0003AF-1I has been removed
Message 1idPGM-00029i-Qs has been removed
Message 1idPwR-0004v5-8L has been removed
Message 1idnzB-0007Iz-LG has been removed
Message 1idWRB-00029m-U9 has been removed
Message 1idjdw-0001hu-Hy has been removed
Message 1idElw-0001kf-Ps has been removed
Message 1idndS-0005Mk-EO has been removed
Message 1idOBS-0006IH-Tm has been removed
Message 1idPut-0004mI-68 has been removed
Message 1idgb5-000375-B1 has been removed
Message 1idxAf-0000O8-HW has been removed
Message 1ictBh-00072Q-5h has been removed

Notice that the previous command will delete all the messages regardless on the time they were added to the queue.

In WHM(Web Host Manager) you can easily manage the mail queue from Home->Email->Mail Queue Manager:

Reference:
exim command line manual

How to check a Softaculous license

Softaculous is the most used auto-install system for scripts like WordPress, Drupal, DokuWiki, Magento etc. You can install them with only a few clicks.

1. If you don’t have server access, you can check a Softaculous license by accessing their web site https://www.softaculous.com/softaculous/verify Just enter the IP address and you will see details about the license – the status, type and the owner of the license.

2. If you have server access, simply go to WHM-> Plugins-> Softaculous – Instant Installs.

3. Another way is from the command line, using the cli.php file

php /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/cli.php -l
root@www [/]# php /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/cli.php -l
Softaculous License : 00000-11111-22222-33333-44444
Type : Premium
Expires (DD/MM/YYYY) : 09/12/2019
License IP : 104.193.100.100
root@www [/]#
Page 1 of 2
1 2