Securing Linux Step-by-Step

From ChekMate Security Group

Contents

BEFORE INSTALLATION

DETERMINE THE SECURITY NEEDS

Define security policies

PHYSICALLY SECURE THE COMPUTER

BIOS SECURITY : PASSWORD PROTECTION,LIMITING REBOOTS

Disable “AUTO” settings

Disable booting from removable media

Set a BIOS password

SCSI BIOS setups

Document BIOS settings

INSTALL LINUX

DISCONNECT THE MACHINE FROM THE NETWORK

SELECT INSTALLATION CLASS : WORKSTATION, SERVER, OR CUSTOM

DEFINE PARTITIONS

Define Workstation partitions

Define Server partitions

Document the partition scheme

SELECT PACKAGES TO INSTALL

Workstation packages

Server packages

Let the installation proceed

CONFIGURE THE SYSTEM SECURITY AND ACCOUNT POLICIES

Shadow Passwords with MD5 hashing

Set passwords for root and all user accounts

FINAL LINUX INSTALLATION RECOMMENDATIONS

Create a boot diskette

Tighten up settings in /etc/inittab

Password protect LILO boots

SET SYSTEM ACCESS SECURITY POLICIES

Check that remote root logins are disabled for TELNET

Check that remote root logins are disabled for FTP

Configure the system accounts that can/cannot log into the system

Configure the system groups that can/cannot use specific resources

CONFIGURE LOGGING

Optimize SYSLOG settings

Configure real-time logging to VTYs

Configure log rotation

Configure remote logging

Synchronize system clock with log server

STEP 3 SECURING WORKSTATION NETWORK CONFIGURATIONS

DISABLE INTERNET DAEMON SERVICES

Edit /etc/inetd.conf and comment out all services

Turn off inetd if there are no services

USE TCP WRAPPERS TO CONTROL ACCESS TO REMAINING INETD SERVICES

Set the default access rule to deny all

Allow access to only specific hosts for specific services

Check the syntax of the access lists with tcpdchk

Set up banners for TCP wrapped services

DISABLE RUN-TIME NETWORK SERVICES

Determine which network services are running

Eliminate unnecessary services

Check for any remaining services

GET THE LATEST VERSIONS OF SOFTWARE

Find security-related updates

Download updates

Install updates

Automate the process

Use AutoRPM to automate updates

Subscribe to security-related mailing lists

CACHING-ONLY DOMAIN NAME SERVICE (DNS)

Disable and remove DNS server software

Set primary and secondary name servers

ELECTRONIC MAIL

Turn off sendmail daemon mode

Define SMTP server for mail clients

Set out-bound SMTP server for sendmail

Set out-bound SMTP server for other mail clients

NFS CLIENT-SIDE SECURITY

Turn off NFS exports and remove NFS daemons

Configure local NFS mounts

LIMIT WORLD WIDE WEB SERVICES TO THE LOCAL HOST

Turn off HTTP and remove the server software

Limit HTTP access to localhost only

REMOVE ANONYMOUS FTP SERVICE

SECURING SERVER NETWORK CONFIGURATIONS

SERVERS: SEE STEPS3.1, 3.2, 3.3, AND 3.4 FOR DISABLING ALL UNNECESSARY SERVICES, SETTING WRAPPERS, AND UPDATING SOFTWARE

INSTALL SECURE SHELL FOR REMOTE ACCESS

Download, compile, and install SSH

Start the SSH daemon

Set up /etc/hosts.allow for SSH access

Generate SSH keys

Use SSH and SCP for remote access

Replace ‘r’ programs with SSH

DOMAIN NAME SERVICE AND BIND VERSION 8

Restrict zone transfers

Restrict queries

Run named in a chroot jail

Create the new user and group

Prepare the chroot directory

Copy configuration files and programs

Copy shared libraries

Set syslogd to listen to named logging

Edit the named init script

Specify a new control channel for ndc

ELECTRONIC MAIL

Turn off SMTP vrfy and expn commands in /etc/sendmail.cf

Define hosts allowed to relay mail

Check that the access database is active

Set access for domains allowed to relay

Set domain name masquerading

Install an alternative MTA

Secure the POP and IMAP daemons

Get the latest version of POP and IMAP daemons

Control access to POP and IMAP with TCP wrappers

Install an alternative POP or IMAP daemon

Install an SSL wrapper for secure POP/IMAP connections

PRINTING SERVICES

List allowed remote hosts in /etc/hosts.lpd

Replace Berkeley lpr/lpd with LPRng

Download and install LPRng

Set remote hosts and/or networks that are allowed access

NETWORK FILE SYSTEM

Set access to RPC services in /etc/hosts.allow

Limit exports to specific machines with specific permissions

SERVER MESSAGE BLOCK (SMB) SAMBA SERVER

Get the latest version of Samba

Limit access to specific hosts

Use encrypted passwords

Remove “guest” or anonymous shares

Set default file creation masks

CENTRAL SYSLOG HOST

Configure syslogd to accept remote log messages

Configure log rotation

FILE TRANSFER PROTOCOL (FTP)

Limit access with TCP wrappers

Limit permitted operations in /etc/ftpaccess

Protect incoming directory

HYPER TEXT TRANSFER PROTOCOL (HTTP) SERVER

Set basic access to default deny

Selectively open access to specific directories

Selectively allow options on specific directories

Selectively use .htaccess to override access control

Use password protection for sensitive data

Use SSL for secure HTTP communications

Download OpenSSL and mod_ssl

Build OpenSSL

Build Apache with mod_ssl module

Start Apache with mod_ssl and test

Read the mod_ssl documentation

TUNING AND PACKET FIREWALLS

KERNELS : THOUGHTS ABOUT CONFIGURATION, RECOMPILING, AND INSTALLING A NEW KERNEL

System optimizations

TCP/IP Receive Window size

PACKET FIREWALLS AND LINUX IP MASQUERADING

Getting more from your external connection with IP Masquerade

A strong /etc/rc.d/rc.firewall ruleset

Double check, install, and test the firewall

Make the ruleset executable

Load the ruleset while at the console of the Linux server

Test the firewall ruleset

Analyze a typical IPCHAINS firewall ruleset hit

Running the firewall ruleset upon every reboot

TOOLS

HOST-BASED MONITORING AND INTRUSION DETECTION

Swatch, the Simple WATCHer

Psionic Logcheck

Tripwire

Tripwire databases

Running Tripwire

Use rpm to verify package files

Psionic PortSentry

HOST-BASED VULNERABILITY ANALYSIS: LOOKING FROM THE INSIDE OUT

Tiger, the Texas A&M system checker

Install and configure Tiger

Running Tiger

Changing Tiger checks

TARA, an updated version of Tiger

NETWORK-BASED VULNERABILITY ANALYSIS: LOOKING FROM THE OUTSIDE IN

SATAN derivatives: SARA and SAINT

Nessus

Nmap port scanner

Commercial products