Linux Security
Linux Security
OpenSSH uses public key cryptography to provide secure authorization. # htpasswd -cm /etc/httpd/conf/private-users user1
# Send a copy to remote loghost. Configure syslogd init
• Configure BIND to run as a normal user. Once BIND has been started, it has the ability
Generating the public key, which is shared with remote systems, and the private New password: <password> to relinquish its privileges, and run as a user with limited abilities instead of root.
# script to run with -r -s [Link] options on log
key which is kept on the local system, is done first to configure OpenSSH. Re-type new password: <password>
# server. Ensure a high level of security on the log # useradd -M -r -d /var/named -s /bin/false named
Adding password for user user1
orion$ ssh-keygen # server! # groupadd -r named
Generating RSA keys: ...ooooooO....ooooooO Be sure to restart apache and test it. This will result in the enabling of double *.info @loghost
Key generation complete.
auth.*;authpriv.* @loghost This account should be used for nothing other than running the name server. Ensure the
Enter file in which to save the key (/home/dave/.ssh/identity): reverse lookups to verify the identity of the remote host. Remove the -c
zone files are readable by the named user. It is then necessary to modify the default
Created directory '/home/dave/.ssh'. option to htpasswd after the first user has been added. Be sure the password
• Restrict access to log directory and syslog files for normal users using: named init script, typically found in /etc/rc.d/init.d/named on Red Hat or
Enter passphrase (empty for no passphrase): <passphrase> file you create is not located within the DocumentRoot to prevent it from
Enter same passphrase again: <passphrase> /etc/init.d/named on Debian:
being downloaded. # chmod 751 /var/log /etc/logrotate.d
Your identification has been saved in /home/dave/.ssh/identity.
Your public key has been saved in /home/dave/.ssh/[Link]. # chmod 640 /etc/[Link] /etc/[Link] /usr/sbin/named -u named -g named
The key fingerprint is: Configuring TCP Wrappers: # chmod 640 /var/log/*log
[Link] dave@orion It is also possible to run named in a “chroot jail” which helps to restrict the damage that
Frequently used to monitor and control access to services listed in can be done should named be subverted.
• Copy Public Key to Remote Host: /etc/[Link]. The [Link] service might be wrapped using:
Install and Configure Tripwire:
host2$ mkdir -m 700 ~dave/.ssh Tripwire is a program that monitors file integrity by maintaining a database of
Critical System Files:
host2$ cp /mnt/floppy/[Link] ~dave/.ssh/authorized_keys ftp stream tcp nowait root /usr/sbin/tcpd [Link] -l -L -i -o
cryptographic signatures for programs and configuration files installed on the
File/Directory Perms Description
• Log in to Remote Host: system, and reports changes in any of these files.
Before the [Link] daemon is spawned, tcpd first determines if the /var/log 751 Directory containing all log files
source is a permitted host. Connection attempts are sent to syslogd. All A database of checksums and other characteristics for the files listed in the /var/log/messages 644 System messages
The SSH client (/usr/bin/ssh) is a drop-in replacement for rlogin and rsh. It services should be disabled by default in /etc/[Link] using the configuration file is created. Each subsequent run compares any differences to /etc/crontab 600 System-wide crontab file
can be used to securely login to a remote host: following: the reference database, and the administrator is notified. /etc/[Link] 640 Syslog daemon configuration file
ALL: ALL /etc/[Link] 640 Controls rotating of system log files
orion$ ssh host2 The greatest level of assurance that can be provided occurs if Tripwire is run /var/log/wtmp 660 Who is logged in now. Use who to view
Enter passphrase for RSA key 'dave@orion': <passphrase> To send an email to the admin and report failed connection attempt: immediately after Linux has been installed and security updates applied, and /var/log/lastlog 640 Who has logged in before. Use last to view
Last login: Sat Aug 15 [Link] 2000 from orion before it is connected to a network.
ALL: ALL: /bin/mail \ /etc/ftpusers 600 List of users that cannot FTP
No mail.
-s “%s connection attempt from %c” admin@[Link] /etc/passwd 644 List of the system’s user accounts
host2$ A text configuration file, called a policy file, is used to define the characteristics for
/etc/shadow 600 Contains encrypted account passwords
each file that are tracked. Your level of paranoia determines the frequency in
Enable specific services in /etc/[Link] using the service name /etc/pam.d 750 PAM configuration files
• Copy Files to Remote Host: which the integrity of the files are checked. Administration requires constant
followed by the host: /etc/[Link] 600 Access control file
attention to the system changes, and can be time-consuming if used for many
The OpenSSH package also includes scp, a secure and improved replacement for sshd: [Link], [Link] /etc/[Link] 600 Access control file
systems. Available in unsupported commercial binary for Red Hat and similar.
rcp. This allows you to securely copy files over a network. [Link]: 192.168.1. /etc/[Link] 600 Boot loader configuration file
# Create policy file from text file /etc/securetty 600 TTY interfaces that allow root logins
orion$ scp /tmp/[Link] host2:/tmp Trailing period indicates entire network should be permitted. Use tcpdchk to /usr/TSS/bin/twadmin -m P [Link] /etc/[Link] 400 Users permitted to ctrl-alt-del
Enter passphrase for RSA key 'dave@orion: verify your access files. A syslog entry will be created for failed attempts. # Initialize database according to policy file /etc/security 700 System access security policy files
[Link] 100% |***************************| 98304 00:00 Access control is performed in the following order: /usr/TSS/bin/tripwire —init /etc/rc.d/init.d 750 Program start-up files on Red Hat systems
It is also possible to encapsulate ordinarily insecure protocols such as IMAP and • Access will be granted when a daemon/client pair matches an entry in # Print database
/etc/init.d 750 Program start-up files on Debian systems
POP within SSH to prevent transmitting clear text passwords to your mail server. the /etc/[Link] file. /usr/TSS/bin/twprint -m d /etc/sysconfig 751 System and network config files on Red Hat
Additionally, the rsync incremental file transfer utility can use SSH to securely • Otherwise, access will be denied when a daemon/client pair matches /etc/[Link] 600 Internet SuperServer configuration file
synchronize two hosts, backup data to a log server securely, or even securely # Generate daily report file /etc/[Link] 400 List of users permitted to use cron
an entry in the /etc/[Link] file. /usr/TSS/bin/tripwire -m c -t 1 -M
connect two subnets across the Internet, effectively creating a virtual private /etc/[Link] 400 List of users denied access to cron
• Otherwise, access will be granted.
network. # Update database according to policy file and report file /etc/ssh 750 Secure Shell configuration files
A non-existing access control file is treated as if it were an empty file. Thus, /usr/TSS/bin/tripwire --update --polfile policy/[Link] \ /etc/[Link] 400 Contains kernel tunable options on recent Red Hat
© 2000 Guardian Digital, Inc. [Link] access control will be turned off if no access control files are present! --twrfile report/<hostname>-<date>.twr
Buffer overflow occurs when a program writes more data to a buffer than it can hold, leading to adjacent memory being overwritten with potentially malicious code. It is one of the leading causes of security advisories and is often linked to root-level privilege escalation via set-user-ID binaries . Kernel patches, such as the OpenWall patch, can mitigate this risk by applying security enhancements that prevent buffer overflow exploitation, such as restricting memory access and limiting information available to non-privileged users .
Packet filtering selectively allows or blocks network packets based on configurable rules that look at packet headers, such as IP addresses and ports. It is a basic defense mechanism on firewalls to control data flow across network interfaces. Implementing packet filtering requires a thorough understanding of network protocols and the ability to create precise rules to minimize false positives and ensure legitimate traffic is not disrupted .
Accurate log files are essential for tracking security events and diagnosing incidents. They provide detailed records of system activities, which are crucial for forensic analysis and building timelines during a security audit. Time synchronization through tools like ntpdate ensures that timestamps in log files are consistent, allowing for correlation with events from other systems and networks. Inaccuracies in time records can obscure events, making it difficult to trace attacks or system failures .
Set-user-ID programs run with elevated privileges, potentially allowing normal users to execute tasks as if they were the program owner. This presents a risk if these programs are exploited through vulnerabilities like buffer overflows, potentially granting unauthorized root access. To mitigate such risks, administrators should audit setuid programs regularly, employ kernel patches that enhance security controls (such as the OpenWall patch), and consider removing the setuid bit when it is not necessary for the program's functionality .
IP Masquerading enables a Linux machine to act as a network gateway, allowing internal hosts to access remote networks using the Linux box's external IP address. This process hides internal IP addresses, making it difficult for attackers to directly access internal systems. It effectively acts as a form of network address translation (NAT), thus providing an additional layer of security by obscuring the internal network structure from external observers .
MD5 checksums provide a quick way to verify file integrity by comparing a file's checksum against a known value, identifying any changes. This ensures that the package has not been tampered with during distribution. However, MD5 is susceptible to collision attacks, where different inputs produce the same checksum, potentially allowing an attacker to substitute an infected package with a matching checksum. Therefore, while useful for basic integrity verification, MD5 should be complemented with stronger hashing algorithms for critical applications .
When automatically updating packages on a production server, it is important to use tools like AutoRPM on Red Hat or apt-get on Debian with caution. Updates can introduce changes that might affect system stability or compatibility with critical applications. Therefore, it is vital to test updates in a controlled environment before deployment and ensure that backups are taken regularly to prevent data loss in case of update-related issues .
Defense in depth involves implementing multiple layers of security controls to protect systems. It ensures that if one security measure fails, others continue to provide protection. This approach includes regularly updating software, applying cryptography to protect data, using firewalls for network segmentation, implementing intrusion detection systems, conducting regular audits, and educating users on security best practices. The goal is to create a comprehensive security posture that addresses various attack vectors and elevates overall system resilience .
Using sudo enhances security by allowing specific commands to be executed with elevated privileges by users who normally do not have root access. This approach requires users to authenticate with their own password, reducing the necessity for sharing the root password. The /etc/sudoers file provides granular control, only permitting authorized commands, which limits potential misuse and enhances auditability compared to the broader access provided by su .
Running unnecessary services increases the attack surface of a system by providing more entry points for attackers. Many services, especially legacy ones, may contain vulnerabilities that can be exploited. Disabling or removing unused services reduces this risk significantly. Administrators should utilize tools like netstat to list active services and appropriately disable them using configuration files or package management tools to ensure that only essential services are operational .