Home > Articles

This chapter is from the book

This chapter is from the book

Configure Common System Services

This section focuses on configuring common system services, including SSH, NTP, syslog, chrony, and localization.

SSH

The Secure Shell (SSH) protocol is designed to replace insecure remote communication operations, such as the telnet, ftp, rlogin, rsh, rcp, and rexec commands/protocols. The primary issue with earlier communication methods is that those methods send data across the network in plaintext rather than in an encrypted format. In some cases, such as with telnet and ftp, this can include sending user account data (such as name and password) across the network in plaintext.

SSH provides a better level of security by encrypting the data sent across the network. SSH has become such a standard in Linux that almost all distributions include both the client and server software by default. In the event that you do not have this software installed on your system, you should install the openssh, openssh-server, openssh-clients, and openssh-askpass software packages.

The /etc/ssh directory is the location where the Secure Shell configuration files are stored. The configuration file for the SSH server is the /etc/ssh/sshd_config file. Don’t confuse this with the /etc/ssh/ssh_config file, which is used to configure client utilities, such as the ssh, scp, and sftp commands.

There are two different SSH protocols that are numbered 1 and 2. These are not versions but rather two separate protocols developed to provide secure data connections. There was a time when both protocols were commonly used, but now almost all SSH clients use only protocol 2. To set the protocol that your SSH server accepts, use the Protocol keyword:

Protocol 2

If you have some older SSH clients that require protocol 1, you can configure your SSH server to accept both protocol connections by using the following keyword setting in the /etc/ssh/sshd_config file:

Protocol 1,2

If you have multiple network cards (or virtual interfaces), you may want to limit the SSH server to listen to only some of the network cards. To do this, use the ListenAddress keyword and specify the IP address assigned to the network cards that SSH should accept connections on:

ListenAddress 192.168.1.100:192.168.1.101

The standard port number that the SSH server listens to is port 22. You can modify the SSH server to listen to another port by using the Port keyword:

Port 2096

You might need to change what sort of log messages you want the SSH server to record. This can be set by using the LogLevel keyword. The levels available are as follows:

  • arrow.jpg QUIET

  • arrow.jpg FATAL

  • arrow.jpg ERROR

  • arrow.jpg INFO

  • arrow.jpg VERBOSE

  • arrow.jpg DEBUG

  • arrow.jpg DEBUG1 (which is the same as DEBUG)

  • arrow.jpg DEBUG2

  • arrow.jpg DEBUG3

Network Time Protocol (NTP)

The Network Time Protocol daemon (ntpd) is a process that ensures the system clock is in sync with the time provided by remote NTP servers. Most of the configuration for this process is handled via the /etc/ntp.conf file. Table 7.1 shows the important settings of the /etc/ntp.conf file.

TABLE 7.1 /etc/ntp.conf File Settings

Option

Description

driftfile

Contains a value that represents the typical delta (change) over time from the NTP-reported time and the system clock. This value is used to regularly update the system clock without having to access an NTP server.

restrict

Used to indicate restrictions for the daemon, including what machines can access this NTP server when it is used as a service.

server

Used to list an NTP server for this machine when it is used as an NTP client.

Here is an example of a typical /etc/ntp.conf file:

# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5),
ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery

# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1

# Hosts on local network are less restricted.
# restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.
  html).
server 0.fedora.pool.ntp.org iburst
server 1.fedora.pool.ntp.org iburst
server 2.fedora.pool.ntp.org iburst
server 3.fedora.pool.ntp.org iburst

# Enable public key cryptography.
#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

The pool.ntp.org address is a link to a cluster of NTP servers that are geographically spread throughout the world. These servers can be freely used within the /etc/ntp.conf file. For example, the following servers are provided by the Fedora project (but note that these are often mirrors, pointing to other systems, so the resulting hostnames for these servers will be different once you have connected to them):


    0.fedora.pool.ntp.org
    1.fedora.pool.ntp.org
    2.fedora.pool.ntp.org
    3.fedora.pool.ntp.org

The ntpq command allows you to perform queries on NTP servers. For example, the ntpq command in the following example displays a summary of the status of NTP servers:

[root@onecoursesource ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset
jitter
============================================================
*propjet.latt.ne 68.110.9.223    2 u  120 1024  377   98.580    7.067
4.413
-services.quadra 208.75.88.4      3 u  272 1024  377   72.504  -10.689
1.612
+mirror          216.93.242.12    3 u  287 1024  377   20.406   -2.555
0.822
+108.61.194.85.v 200.23.51.102    2 u  741 1024  377   69.403   -3.670
1.610

Table 7.2 lists some important options to the ntpq command.

TABLE 7.2 ntpq Command Options

Option

Description

-d

Enables debugging mode.

-n

Lists host IP addresses rather than names.

-p

Prints a list of all peers.

Syslog

The syslog service has existed since 1980. Although it was advanced at the time it was created, its limitations have grown over time as more complex logging techniques have become required.

In the mid-2000s, the rsyslog service was created as an extension of the traditional syslog service. The rsyslog service extends the capabilities of syslog through the inclusion of modules.

The configuration of syslog and rsyslog services is consistent, with the exception of slightly different naming conventions (for example, rsyslog.conf versus syslog.conf) and additional features available in the log files.

The syslogd or rsyslogd daemon is responsible for logging of application and system events. It determines which events to log and where to place log entries, based on configuration settings in the /etc/syslog.conf file.

Table 7.3 describes some important options to the syslogd and rsyslogd commands.

TABLE 7.3 syslogd and rsyslogd Command Options

Option

Description

-d

Enables debugging mode.

-f

Specifies the configuration file (with /etc/syslog.conf as the default).

-m x

Creates a timestamp in the log files every x minutes. (You can set x to 0 to omit timestamps.)

-r

Enables the syslogd daemon to accept logs from remote systems.

-S

Enables verbose mode.

-x

Disables DNS lookups for IP addresses.

The /etc/rsyslog.conf file is one of the configuration files for the rsyslogd daemon. The following is a typical rsyslog.conf file with the comments and blank lines removed (along with the modules):

[root@OCS ~]# grep -v "^$" /etc/rsyslog.conf | grep -v "^#"
*.info;mail.none;authpriv.none;cron.none /var/log/messages
authpriv.*                               /var/log/secure
mail.*                                   -/var/log/maillog
cron.*                                    /var/log/cron
*.emerg                                    *
uucp,news.crit                            /var/log/spooler
local7.*                                 /var/log/boot.log

Every line represents one logging rule that is broken into two primary parts: the selector (for example, uucp,news.crit) and the action (/var/log/spooler). The selector is also broken into two parts: the facility (uucp,news) and the priority (crit). Note that when a priority is provided, it means “this priority and all priorities of a higher level.”

The following list shows the available facilities in order from lower level to higher level:

  • arrow.jpg auth (or security)

  • arrow.jpg authpriv

  • arrow.jpg cron

  • arrow.jpg daemon

  • arrow.jpg kern

  • arrow.jpg lpr

  • arrow.jpg mail

  • arrow.jpg mark

  • arrow.jpg news

  • arrow.jpg syslog

  • arrow.jpg user

  • arrow.jpg uucp

  • arrow.jpg local0 through local7

The following list shows the available priority levels:

  • arrow.jpg debug

  • arrow.jpg info

  • arrow.jpg notice

  • arrow.jpg warning (or warn)

  • arrow.jpg err (or error)

  • arrow.jpg crit

  • arrow.jpg alert

  • arrow.jpg emerg (or panic)

The following list shows the available “actions”, which are really just where the log entry should be sent:

  • arrow.jpg Regular file (where using - before the filename prevents syncing with every log entry, thus reducing hard drive writes)

  • arrow.jpg Named pipes

  • arrow.jpg Console or terminal devices

  • arrow.jpg Remote hosts

  • arrow.jpg Users, which write to the specified user’s terminal windows (where * specifies all users)

chrony

Traditionally, the NTP server on Linux has been the ntpd server (discussed earlier in this chapter, in the “Network Time Protocol [NTP]” section). A newer alternative, chrony, provides some benefits over the ntpd server, including:

  • arrow.jpg Faster synchronization

  • arrow.jpg Typically more accurate time

  • arrow.jpg Improved response to clock frequency changes

  • arrow.jpg No need for periodic polling of other NTP servers

  • arrow.jpg Smaller (less memory and CPU utilization)

Pearson IT Certification Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Pearson IT Certification and its family of brands. I can unsubscribe at any time.