Services and Firewalling

This is paper 3 of 4 of my server series.

The topics we will be covering are in today's paper are:

2.5. Secure shell
2.6. syslog
2.7. cron
2.8. ipfw and natd


2.5. secure shell

SSH means Secure Shell. With origin SSH is a replacement of the Berkeley R * orders such as rsh, rlogin or CCP considered as far from sure. SSH uses to make safe the transmission a tunnel crypté between the 2 machines. SSH quickly exceeded all waitings and it became a replacement interesting for telnet or ftp when they are necessary for regular users having an account on the machine in their offering an access method remotely highly protected and supported very well. In particular OpenSSH is a free and re-coded version protocol SSH and provides a customer and a waiter for many Unix platforms. It is him whom we now will use for the configuration of SSH.

First of all we will publish the file of configuration of the daemon sshd.

($:~)=> ee /etc/ssh/sshd_config


# This is ssh server systemwide configuration file.

Port 22

# avoid SSHv1 subjected to several vulnerabilities
Protocol 2,1

# when you copy this file for your jail to use think of putting
# here alias your jail.

ListenAddress 127.0.0.1, public_IP, jail_IP

HostKey /etc/ssh/ssh_host_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
ServerKeyBits 768
LoginGraceTime 60
KeyRegenerationInterval 3600
RhostsAuthentication no
RSAAuthentication yes
PubkeyAuthentication yes

# preferred order of the authentification and encryption algorithms
Ciphers blowfish-cbc,aes256-cbc,aes192-cbc,aes128-cbc,3des-cbc,cast128-cbc,arcfour
MACs    hmac-sha1,hmac-md5,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

# sending of a message after an interval given
# and deconnexion after several sendings
KeepAlive yes
ClientAliveInterval 30
ClientAliveCountMax 5

# to avoid the imitations flooding A of the repeated attempts at connection,
# we install a kind of quotas on the level of the management of connections.  
# 10 for the number of connections not auhentifiees, 40 for the percentage of
# refusal after the first number reached, and 50 meaning that at the end of 50
# tentative any connection not authentifiee is refusee.
MaxStartups 10:40:50

# here we eliminate the vulnerabilites dregs with the files ~/.rhosts and
# ~/.shosts and has their relations of confidence.
IgnoreRhosts yes

# verifier permissions and ownership of the files and of/home before accepting
# a login
StrictModes yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd yes

# Syslog
SyslogFacility AUTH
LogLevel DEBUG

# Below us privilegions the use of cles RSA and DSA for
# authentification instead of the password
PasswordAuthentication no

# if you choississez to put the preceding option has yes, add that below
# to prohibit passwords empty
# PermitEmptyPasswords No

# decontaminates the authentification s/key
SkeyAuthentication No
KbdInteractiveAuthentication yes
ChallengeResponseAuthentication No

# these blocks are relative has authentification Kerberos
# KerberosAuthentication No
# KerberosOrLocalPasswd yes
# AFSTokenPassing No
# KerberosTicketCleanup No
# Kerberos TGT Passing does only work with the AFS kaserver
# KerberosTgtPassing yes

PermitRootLogin no
CheckMail yes
UseLogin yes

# we do not recommend it because of its relative experimentalite but this
# line allows you the case echeant to use sftp.  
# Subsystem sftp/usr/libexec/sftp-server




It does not remain us now than has to publish the file rc.conf once again in order to make sure that sshd will launch out well to the demarrage. We thus transform the line sshd_enable="NO "into sshd_enable="YES" and also adjoinions we to him the line sshd_flags="-4 "in order to limit the use has IPv4 connections. To generate your keys it will then be enough for you to carry out ssh-keygen; although this one is of out and already used by rc.network with sshd_enable.

You will be able to finally decide not to offer of Shell to your distant users. This can be to carry out using chpass or of chsh while specifying like Shell/sbin/nologin.

($:~)=> chsh -s /sbin/nologin user

2.6. logging

We now will lean we on facilitate that us FreeBSD in the logging of the various activities system and user offers. We more particularly will study the system accounting, the system logging and the analysis of these logs by means automate.

Under FreeBSD, we have the possibility of activating the system accounting which makes it possible to us to record and to recapitulate the orders carried out and allows us to store information detailed on the resources system used, their distribution between the users, and to supervise the system. With this intention, we have accton and of its. Accton makes it possible to activate or of desactiver the system accounting

($:~)=> accton /var/account/acct

We specifions here a file towards which redirects give them accounting will be, for desactiver it is enough to executer the same order without the file in argument. To consult give them accounting it is enough to executer its with a classification by user

($:~)=> sa -u

We thus obtain detaillées statistics of the system activity by users. You can also serve to you as the option rc.conf accounting_enable="YES "with the same effect.

We also have has our provision the syslog family. First of all we have syslogd which enables us to record the error messages and other messages systems in the repertoire/var/log. To activate it, we once again publish rc.conf to add the following entrees to it

syslogd_enable="YES"
syslogd_flags="-ss -m 0"

We have moreover adds flags making so that the daemon syslog functions in secure mode without possibility of log or transmission since the exterior. Then for afiner the recording of the messages, we will publish/etc/syslog.conf. Syslog.conf possede a whole syntax particuliere:

O The blocks of directives are classes by program
O the directives are form facility.level followed destination of the messages which can as well be a file as a user or a peripheral.

Different the facility is:

By syncro
06 Dec 2003