Book description
Gain a firm practical understanding of how to secure your Linux system from intruders, malware attacks, and other cyber threats Purchase of the print or Kindle book includes a free eBook in PDF format.
Key Features
- Discover security techniques to prevent malware from infecting a Linux system, and detect it
- Prevent unauthorized people from breaking into a Linux system
- Protect important and sensitive data from being revealed to unauthorized persons
Book Description
The third edition of Mastering Linux Security and Hardening is an updated, comprehensive introduction to implementing the latest Linux security measures, using the latest versions of Ubuntu and AlmaLinux.
In this new edition, you will learn how to set up a practice lab, create user accounts with appropriate privilege levels, protect sensitive data with permissions settings and encryption, and configure a firewall with the newest firewall technologies. You’ll also explore how to use sudo to set up administrative accounts with only the privileges required to do a specific job, and you’ll get a peek at the new sudo features that have been added over the past couple of years. You’ll also see updated information on how to set up a local certificate authority for both Ubuntu and AlmaLinux, as well as how to automate system auditing. Other important skills that you’ll learn include how to automatically harden systems with OpenSCAP, audit systems with auditd, harden the Linux kernel configuration, protect your systems from malware, and perform vulnerability scans of your systems. As a bonus, you’ll see how to use Security Onion to set up an Intrusion Detection System.
By the end of this new edition, you will confidently be able to set up a Linux server that will be secure and harder for malicious actors to compromise.
What you will learn
- Prevent malicious actors from compromising a production Linux system
- Leverage additional features and capabilities of Linux in this new version
- Use locked-down home directories and strong passwords to create user accounts
- Prevent unauthorized people from breaking into a Linux system
- Configure file and directory permissions to protect sensitive data
- Harden the Secure Shell service in order to prevent break-ins and data loss
- Apply security templates and set up auditing
Who this book is for
This book is for Linux administrators, system administrators, and network engineers interested in securing moderate to complex Linux environments. Security consultants looking to enhance their Linux security skills will also find this book useful. Working experience with the Linux command line and package management is necessary to understand the concepts covered in this book.
Table of contents
- Preface
- Section 1: Setting up a Secure Linux System
-
Running Linux in a Virtual Environment
- Looking at the threat landscape
- Why do security breaches happen?
- Keeping up with security news
- Differences between physical, virtual, and cloud setups
-
Introducing VirtualBox and Cygwin
- Installing a virtual machine in VirtualBox
- Installing the EPEL repository on the CentOS 7 virtual machine
- Installing the EPEL repository on the AlmaLinux 8/9 virtual machines
- Configuring a network for VirtualBox virtual machines
- Creating a virtual machine snapshot with VirtualBox
- Using Cygwin to connect to your virtual machines
- Using the Windows 10 SSH client to interface with Linux virtual machines
- Using the Windows 11 SSH client to interface with Linux virtual machines
- Keeping the Linux systems updated
- Summary
- Questions
- Further reading
- Answers
-
Securing Administrative User Accounts
- The dangers of logging in as the root user
- The advantages of using sudo
- Setting up sudo privileges for full administrative users
- Setting up sudo for users with only certain delegated privileges
-
Advanced tips and tricks for using sudo
- The sudo timer
- View your sudo privileges
- Preventing users from having root shell access
- Preventing users from using shell escapes
- Preventing users from using other dangerous programs
- Limiting the user’s actions with commands
- Letting users run as other users
- Preventing abuse via a user’s shell scripts
- Detecting and deleting default user accounts
- New sudo features
- Special sudo considerations for SUSE and OpenSUSE
- Summary
- Questions
- Further reading
- Answers
-
Securing Normal User Accounts
- Locking down users’ home directories the Red Hat way
- Locking down users’ home directories the Debian/Ubuntu way
- Enforcing strong password criteria
- Setting and enforcing password and account expiration
- Configuring default expiry data for useradd for Red Hat-type systems only
- Setting expiry data on a per-account basis with useradd and usermod
- Setting expiry data on a per-account basis with chage
- Preventing brute-force password attacks
- Locking user accounts
- Locking the root user account
- Setting up security banners
- Detecting compromised passwords
- Understanding centralized user management
- Samba on Linux
- Summary
- Questions
- Further reading
- Answers
-
Securing Your Server with a Firewall – Part 1
- Technical requirements
- An overview of the Linux firewall
- An overview of iptables
- nftables – a more universal type of firewall system
- Summary
- Questions
- Further reading
- Answers
-
Securing Your Server with a Firewall — Part 2
- Technical requirements
- The Uncomplicated Firewall for Ubuntu systems
-
firewalld for Red Hat systems
- Verifying the status of firewalld
- Working with firewalld zones
- Adding services to a firewalld zone
- Adding ports to a firewalld zone
- Blocking ICMP
- Using panic mode
- Logging dropped packets
- Using firewalld rich language rules
- Looking at iptables rules in RHEL/CentOS 7 firewalld
- Creating direct rules in RHEL/CentOS 7 firewalld
- Looking at nftables rules in RHEL/AlmaLinux 8 and 9 firewalld
- Creating direct rules in RHEL/AlmaLinux firewalld
- Summary
- Questions
- Further reading
- Answers
-
Encryption Technologies
- GNU Privacy Guard (GPG)
- Encrypting partitions with Linux Unified Key Setup (LUKS)
- Encrypting directories with eCryptfs
- Encrypting the swap partition with eCryptfs
- Using VeraCrypt for cross-platform sharing of encrypted containers
- OpenSSL and the Public Key Infrastructure
- Introducing quantum-resistant encryption algorithms
- Summary
- Questions
- Further reading
- Answers
-
SSH Hardening
- Ensuring that SSH protocol 1 is disabled
-
Creating and managing keys for passwordless logins
- Creating a user’s SSH key set
- Transferring the public key to the remote server
- Disabling root user login
- Disabling username/password logins
- Enabling two-factor authentication
- Configuring Secure Shell with strong encryption algorithms
- Scanning for enabled SSH algorithms
- Disabling weak SSH encryption algorithms
- Setting system-wide encryption policies on RHEL 8/9 and AlmaLinux 8/9
- Configuring more detailed logging
- Configuring access control with whitelists and TCP Wrappers
- Configuring automatic logouts and security banners
- Configuring other miscellaneous security settings
- Setting different configurations for different users and groups
- Creating different configurations for different hosts
- Setting up a chroot environment for SFTP users
- Sharing a directory with SSHFS
- Remotely connecting from Windows desktops
- Summary
- Questions
- Further reading
- Answers
- Section 2: Mastering File and Directory Access Control (DAC)
-
Mastering Discretionary Access Control
- Using chown to change ownership of files and directories
- Summary
- Questions
- Further reading
- Answers
-
Access Control Lists and Shared Directory Management
- Creating an ACL for either a user or a group
- Creating an inherited ACL for a directory
- Removing a specific permission by using an ACL mask
- Using the tar --acls option to prevent the loss of ACLs during a backup
- Creating a user group and adding members to it
- Creating a shared directory
- Setting the SGID bit and the sticky bit on the shared directory
- Using ACLs to access files in the shared directory
- Summary
- Questions
- Further reading
- Answers
- Section 3: Advanced System Hardening Techniques
-
Implementing Mandatory Access Control with SELinux and AppArmor
- How SELinux can benefit a systems administrator
- Setting security contexts for files and directories
- Troubleshooting with setroubleshoot
- Working with SELinux policies
- How AppArmor can benefit a systems administrator
- Exploiting a system with an evil Docker container
- Summary
- Questions
- Further reading
- Answers
-
Kernel Hardening and Process Isolation
- Understanding the /proc filesystem
- Setting kernel parameters with sysctl
- Configuring the sysctl.conf file
- Understanding process isolation
- Summary
- Questions
- Further reading
- Answers
-
Scanning, Auditing, and Hardening
- Installing and updating ClamAV and maldet
- Scanning with ClamAV and maldet
- Scanning for rootkits with Rootkit Hunter
- Performing a quick malware analysis with strings and VirusTotal
- Understanding the auditd daemon
- Using ausearch and aureport
- Auditing files and directories with inotifywait
- Applying OpenSCAP policies with oscap
- Summary
- Questions
- Further reading
- Answers
-
Logging and Log Security
- Understanding the Linux system log files
- Understanding rsyslog
- Understanding journald
- Making things easier with Logwatch
- Setting up a remote log server
- Maintaining Logs in Large Enterprises
- Summary
- Questions
- Further reading
- Answers
- Vulnerability Scanning and Intrusion Detection
- Prevent Unwanted Programs from Running
- Security Tips and Tricks for the Busy Bee
- Other Books You May Enjoy
- Index
Product information
- Title: Mastering Linux Security and Hardening - Third Edition
- Author(s):
- Release date: February 2023
- Publisher(s): Packt Publishing
- ISBN: 9781837630516
You might also like
book
Mastering Linux Security and Hardening - Second Edition
A comprehensive guide to securing your Linux system against cyberattacks and intruders Key Features Deliver a …
book
Linux Basics for Hackers
If you’re getting started along the exciting path of hacking, cybersecurity, and pentesting, Linux Basics for …
book
Linux Fundamentals, 2nd Edition
The Linux world is constantly changing, requiring new knowledge and skills to work as a Linux …
video
Linux Fundamentals, 2nd Edition
10+ Hours of Video Instruction More than 10 hours of video instruction to get you up …