Register · · Password forgotten? · |
Expert insight - Tevault D. A. / Тево Д. А. - Mastering Linux Security and Hardening: A practical guide to protecting your Linux system from cyber attacks, 3rd Edition / Освойте безопасность
|
![]() |
Home » Books and magazines » Computer literature » Mac OS; Linux, FreeBSD and others *NIX |
DL-List and Torrent activity | |
Size: 64 MB | Registered: 1 year 3 months | Completed: 6 times | |
|
Author | Message | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
iPhone ® Gender: Longevity: 9 years 8 months Posts: 2207 |
Mastering Linux Security and Hardening: A practical guide to protecting your Linux system from cyber attacks, 3rd Edition / Освойте безопасность Linux: практическое руководство по защите вашей системы Linux от кибератак, 3-е издание
Год издания: 2023 Автор: Tevault D. A. / Тево Д. А. Издательство: Packt Publishing ISBN: 978-1-83763-051-6 Серия: Expert insight Язык: Английский Формат: PDF, EPUB Качество: Издательский макет или текст (eBook) Интерактивное оглавление: Да Количество страниц: 619 Описание: Gain a firm practical understanding of how to secure your Linux system from intruders, malware attacks, and other cyber threats 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. Получите четкое практическое представление о том, как защитить вашу систему Linux от злоумышленников, атак вредоносных программ и других киберугроз Ключевые функции Узнайте о методах безопасности, позволяющих предотвратить заражение системы Linux вредоносными программами, и обнаруживайте их Предотвращайте проникновение посторонних лиц в систему Linux Защитите важные и конфиденциальные данные от разглашения посторонним лицам Описание книги Третье издание руководства Mastering Linux Security and Hardening представляет собой обновленное всеобъемлющее введение в реализацию новейших мер безопасности Linux с использованием последних версий Ubuntu и AlmaLinux. В этом новом издании вы узнаете, как настроить практическую лабораторию, создать учетные записи пользователей с соответствующими уровнями привилегий, защитить конфиденциальные данные с помощью настроек разрешений и шифрования, а также настроить брандмауэр с использованием новейших технологий. Вы также узнаете, как использовать sudo для настройки учетных записей администратора только с привилегиями, необходимыми для выполнения определенной работы, и познакомитесь с новыми функциями sudo, которые были добавлены за последние пару лет. Вы также увидите обновленную информацию о том, как настроить локальный центр сертификации как для Ubuntu, так и для AlmaLinux, а также о том, как автоматизировать системный аудит. Другие важные навыки, которым вы научитесь, включают в себя автоматическую защиту систем с помощью OpenSCAP, аудит систем с помощью auditd, настройку ядра Linux, защиту ваших систем от вредоносных программ и выполнение сканирования ваших систем на уязвимости. В качестве бонуса вы увидите, как использовать Security Onion для настройки системы обнаружения вторжений. К концу этого нового выпуска вы с уверенностью сможете настроить сервер Linux, который будет защищен и который злоумышленникам будет сложнее скомпрометировать. Что вы узнаете Предотвратите компрометацию рабочей системы Linux злоумышленниками Используете дополнительные функции и возможности Linux в этой новой версии Используете заблокированные домашние каталоги и надежные пароли для создания учетных записей пользователей Предотвратите проникновение посторонних лиц в систему Linux Настройте права доступа к файлам и каталогам для защиты конфиденциальных данных Упростите службу Secure Shell, чтобы предотвратить взломы и потерю данных Примените шаблоны безопасности и настроите аудит Для кого предназначена эта книга Эта книга предназначена для администраторов Linux, системных администраторов и сетевых инженеров, заинтересованных в обеспечении безопасности сред Linux сложного уровня. Консультанты по безопасности, желающие улучшить свои навыки в области безопасности Linux, также найдут эту книгу полезной. Опыт работы с командной строкой Linux и управлением пакетами необходим для понимания концепций, описанных в этой книге. ОглавлениеPreface xxiSection I: Setting up a Secure Linux System 1 Chapter 1: Running Linux in a Virtual Environment 3 Looking at the threat landscape 4 Why do security breaches happen? 4 Keeping up with security news 5 Differences between physical, virtual, and cloud setups 6 Introducing VirtualBox and Cygwin 6 Installing a virtual machine in VirtualBox • 7 Installing the EPEL repository on the CentOS 7 virtual machine • 11 Installing the EPEL repository on the AlmaLinux 8/9 virtual machines • 12 Configuring a network for VirtualBox virtual machines • 13 Creating a virtual machine snapshot with VirtualBox • 14 Using Cygwin to connect to your virtual machines • 14 Installing Cygwin on your Windows host • 14 Using the Windows 10 SSH client to interface with Linux virtual machines • 15 Using the Windows 11 SSH client to interface with Linux virtual machines • 18 Cygwin versus the Windows shell • 18 Keeping the Linux systems updated 19 Updating Debian-based systems • 19 Configuring auto updates for Ubuntu • 20 Updating Red Hat 7-based systems • 22 Updating Red Hat 8/9-based systems • 26 Managing updates in an enterprise • 27 Summary 27 Questions 28 Further reading 28 Answers 29 Chapter 2: Securing Administrative User Accounts 31 The dangers of logging in as the root user 31 The advantages of using sudo 32 Setting up sudo privileges for full administrative users 33 Adding users to a predefined admin group • 33 Creating an entry in the sudo policy file • 35 Setting up sudo for users with only certain delegated privileges 36 Hands-on lab for assigning limited sudo privileges • 39 Advanced tips and tricks for using sudo 41 The sudo timer • 41 View your sudo privileges • 41 Hands-on lab for disabling the sudo timer • 42 Preventing users from having root shell access • 43 Preventing users from using shell escapes • 43 Preventing users from using other dangerous programs • 46 Limiting the user’s actions with commands • 47 Letting users run as other users • 47 Preventing abuse via a user’s shell scripts • 48 Detecting and deleting default user accounts • 50 New sudo features 51 Special sudo considerations for SUSE and OpenSUSE 51 Summary 53 Questions 54 Further reading 55 Answers 55 Chapter 3: Securing Normal User Accounts 57 Locking down users’ home directories the Red Hat way 57 Locking down users’ home directories the Debian/Ubuntu way 58 useradd on Debian/Ubuntu • 59 adduser on Debian/Ubuntu • 60 Hands-on lab for creating an encrypted home directory with adduser • 61 Enforcing strong password criteria 62 Installing and configuring pwquality • 63 Hands-on lab for setting password complexity criteria • 65 Setting and enforcing password and account expiration 66 Configuring default expiry data for useradd for Red Hat-type systems only 67 Setting expiry data on a per-account basis with useradd and usermod 69 Setting expiry data on a per-account basis with chage 70 Hands-on lab for setting account and password expiry data • 72 Preventing brute-force password attacks 73 Configuring the pam_tally2 PAM module on CentOS 7 • 73 Hands-on lab for configuring pam_tally2 on CentOS 7 • 74 Configuring pam_faillock on AlmaLinux 8/9 • 75 Hands-on lab for configuring pam_faillock on AlmaLinux 8 or AlmaLinux 9 • 75 Configuring pam_faillock on Ubuntu 20.04 and Ubuntu 22.04 • 77 Hands-on lab for configuring pam_faillock on Ubuntu 20.04 and Ubuntu 22.04 • 77 Locking user accounts 78 Using usermod to lock a user account • 78 Using passwd to lock user accounts • 79 Locking the root user account 80 Setting up security banners 80 Using the motd file • 81 Using the issue file • 82 Using the issue.net file • 83 Detecting compromised passwords 83 Hands-on lab for detecting compromised passwords • 86 Understanding centralized user management 87 Microsoft Active Directory • 87 Samba on Linux 87 FreeIPA/Identity Management on RHEL-type distros • 88 Summary 90 Questions 90 Further reading 91 Answers 91 Chapter 4: Securing Your Server with a Firewall – Part 1 93 Technical requirements 93 An overview of the Linux firewall 94 An overview of iptables 95 x Table of Contents Mastering the basics of iptables • 95 Blocking ICMP with iptables • 99 Blocking everything that isn’t allowed with iptables • 101 Hands-on lab for basic iptables usage • 104 Blocking invalid packets with iptables • 105 Restoring the deleted rules • 111 Hands-on lab for blocking invalid IPv4 packets • 112 Protecting IPv6 • 113 Hands-on lab for ip6tables • 116 nftables – a more universal type of firewall system 117 Learning about nftables tables and chains • 118 Getting started with nftables • 118 Configuring nftables on Ubuntu • 118 Using nft commands • 122 Hands-on lab for nftables on Ubuntu • 127 Summary 129 Questions 129 Further reading 130 Answers 130 Chapter 5: Securing Your Server with a Firewall — Part 2 131 Technical requirements 132 The Uncomplicated Firewall for Ubuntu systems 132 Configuring ufw • 132 Working with the ufw configuration files • 134 Hands-on lab for basic ufw usage • 137 firewalld for Red Hat systems 139 Verifying the status of firewalld • 140 Working with firewalld zones • 140 Adding services to a firewalld zone • 144 Adding ports to a firewalld zone • 149 Blocking ICMP • 150 Using panic mode • 152 Logging dropped packets • 153 Using firewalld rich language rules • 154 Looking at iptables rules in RHEL/CentOS 7 firewalld • 156 Creating direct rules in RHEL/CentOS 7 firewalld • 158 Table of Contents xi Looking at nftables rules in RHEL/AlmaLinux 8 and 9 firewalld • 161 Creating direct rules in RHEL/AlmaLinux firewalld • 161 Hands-on lab for firewalld commands • 162 Summary 165 Questions 165 Further reading 166 Answers 166 Chapter 6: Encryption Technologies 167 GNU Privacy Guard (GPG) 168 Hands-on lab – creating your GPG keys • 169 Hands-on lab – symmetrically encrypting your own files • 171 Hands-on lab – encrypting files with public keys • 173 Hands-on lab – signing a file without encryption • 177 Encrypting partitions with Linux Unified Key Setup (LUKS) 178 Disk encryption during operating system installation • 179 Hands-on lab – adding an encrypted partition with LUKS • 181 Configuring the LUKS partition to mount automatically • 185 Hands-on lab – configuring the LUKS partition to mount automatically • 186 Encrypting directories with eCryptfs 187 Hands-on lab – encrypting a home directory for a new user account • 188 Creating a private directory within an existing home directory • 188 Hands-on lab – encrypting other directories with eCryptfs • 190 Encrypting the swap partition with eCryptfs 192 Using VeraCrypt for cross-platform sharing of encrypted containers 192 Hands-on lab – getting and installing VeraCrypt • 193 Hands-on lab – creating and mounting a VeraCrypt volume in console mode • 194 Using VeraCrypt in GUI mode • 196 OpenSSL and the Public Key Infrastructure 197 Commercial certificate authorities • 198 Creating keys, certificate signing requests, and certificates • 201 Creating a self-signed certificate with an RSA key • 201 Creating a self-signed certificate with an Elliptic Curve key • 202 Creating an RSA key and a Certificate Signing Request • 203 Creating an EC key and a CSR • 204 Creating an on-premises CA • 205 Hands-on lab – setting up a Dogtag CA • 206 xii Table of Contents Adding a CA to an operating system • 210 Hands-on lab – exporting and importing the Dogtag CA certificate • 210 Importing the CA into Windows • 211 OpenSSL and the Apache webserver • 212 Hardening Apache SSL/TLS on Ubuntu • 212 Hardening Apache SSL/TLS on RHEL 9/AlmaLinux 9 • 213 Setting FIPS mode on RHEL 9/AlmaLinux 9 • 215 Hardening Apache SSL/TLS on RHEL 7/CentOS 7 • 217 Setting up mutual authentication • 218 Introducing quantum-resistant encryption algorithms 218 Summary 219 Questions 219 Further reading 220 Answers 221 Chapter 7: SSH Hardening 223 Ensuring that SSH protocol 1 is disabled 224 Creating and managing keys for passwordless logins 224 Creating a user’s SSH key set • 225 Transferring the public key to the remote server • 228 Hands-on lab – creating and transferring SSH keys • 230 Disabling root user login • 231 Disabling username/password logins • 232 Hands-on lab – Disabling root login and password authentication • 232 Enabling two-factor authentication • 233 Hands-on lab — Setting up two-factor authentication on Ubuntu 22.04 • 234 Hands-on lab – Using Google Authenticator with key exchange on Ubuntu • 236 Hands-on lab — Setting up two-factor authentication on AlmaLinux 8 • 237 Hand-on lab — Using Google Authenticator with key exchange on AlmaLinux 8 • 238 Configuring Secure Shell with strong encryption algorithms • 238 Understanding SSH encryption algorithms • 239 Scanning for enabled SSH algorithms • 242 Hands-on lab – Scanning with Nmap • 242 Disabling weak SSH encryption algorithms • 243 Hands-on lab – disabling weak SSH encryption algorithms – Ubuntu 22.04 • 243 Hands-on lab – disabling weak SSH encryption algorithms – CentOS 7 • 244 Setting system-wide encryption policies on RHEL 8/9 and AlmaLinux 8/9 • 246 Table of Contents xiii Hands-on lab – setting encryption policies on AlmaLinux 9 • 247 Configuring more detailed logging • 248 Hands-on lab – configuring more verbose SSH logging • 249 Configuring access control with whitelists and TCP Wrappers 250 Configuring whitelists within sshd_config • 251 Hands-on lab – configuring whitelists within sshd_config • 251 Configuring whitelists with TCP Wrappers • 252 Configuring automatic logouts and security banners 254 Configuring automatic logout for both local and remote users • 254 Configuring automatic logout in sshd_config • 254 Creating a pre-login security banner • 255 Configuring other miscellaneous security settings 255 Disabling X11 forwarding • 255 Disabling SSH tunneling • 256 Changing the default SSH port • 257 Managing SSH keys • 258 Setting different configurations for different users and groups 261 Creating different configurations for different hosts 261 Setting up a chroot environment for SFTP users 262 Creating a group and configuring the sshd_config file • 263 Hands-on lab – Setting up a chroot directory for the sftpusers group • 264 Sharing a directory with SSHFS 265 Hands-on lab – Sharing a directory with SSHFS • 265 Remotely connecting from Windows desktops 267 Summary 272 Questions 273 Further reading 275 Answers 275 Section II: Mastering File and Directory Access Control (DAC) 277 Chapter 8: Mastering Discretionary Access Control 279 Using chown to change ownership of files and directories • 279 Using chmod to set permissions on files and directories • 281 Setting permissions with the symbolic method • 282 Setting permissions with the numerical method • 282 xiv Table of Contents Using SUID and SGID on regular files • 284 The security implications of the SUID and SGID permissions • 285 Finding spurious SUID or SGID files • 286 Preventing SUID and SGID usage on a partition • 288 Using extended file attributes to protect sensitive files • 288 Setting the a attribute • 290 Setting the i attribute • 291 Securing system configuration files • 293 Summary 295 Questions 295 Further reading 298 Answers 298 Chapter 9: Access Control Lists and Shared Directory Management 301 Creating an ACL for either a user or a group 301 Creating an inherited ACL for a directory 304 Removing a specific permission by using an ACL mask 306 Using the tar --acls option to prevent the loss of ACLs during a backup 307 Creating a user group and adding members to it 309 Adding members as we create their user accounts • 310 Using usermod to add an existing user to a group • 310 Adding users to a group by editing the /etc/group file • 310 Creating a shared directory 311 Setting the SGID bit and the sticky bit on the shared directory 312 Using ACLs to access files in the shared directory 315 Setting the permissions and creating the ACL • 315 Hands-on lab – creating a shared group directory • 317 Summary 318 Questions 318 Further reading 320 Answers 321 Table of Contents xv Section III: Advanced System Hardening Techniques 323 Chapter 10: Implementing Mandatory Access Control with SELinux and AppArmor 325 How SELinux can benefit a systems administrator 326 Setting security contexts for files and directories 327 Installing the SELinux tools • 328 Creating web content files with SELinux enabled • 329 Fixing an incorrect SELinux context • 332 Using chcon • 332 Using restorecon • 333 Using semanage • 334 Hands-on lab – SELinux type enforcement • 336 Troubleshooting with setroubleshoot 337 Viewing setroubleshoot messages • 337 Using the graphical setroubleshoot utility • 338 Troubleshooting in permissive mode • 340 Working with SELinux policies 342 Viewing Booleans • 342 Configuring the Booleans • 344 Protecting your web server • 345 Protecting network ports • 346 Creating custom policy modules • 349 Hands-on lab – SELinux Booleans and ports • 351 How AppArmor can benefit a systems administrator 351 Looking at AppArmor profiles • 352 Working with AppArmor command-line utilities • 355 Troubleshooting AppArmor problems • 358 Troubleshooting an AppArmor profile – Ubuntu 16.04 • 358 Troubleshooting an AppArmor profile – Ubuntu 18.04 • 361 Hands-on lab – Troubleshooting an AppArmor profile • 362 Troubleshooting Samba problems in Ubuntu 22.04 • 363 xvi Table of Contents Exploiting a system with an evil Docker container 364 Hands-on lab – Creating an evil Docker container • 364 Summary 366 Questions 367 Further reading 369 Answers 369 Chapter 11: Kernel Hardening and Process Isolation 371 Understanding the /proc filesystem 372 Looking at user-mode processes • 372 Looking at kernel information • 374 Setting kernel parameters with sysctl 376 Configuring the sysctl.conf file 377 Configuring sysctl.conf – Ubuntu • 378 Configuring sysctl.conf – CentOS and AlmaLinux • 381 Setting additional kernel-hardening parameters • 382 Hands-on lab – scanning kernel parameters with Lynis • 383 Preventing users from seeing each others’ processes • 385 Understanding process isolation 386 Understanding Control Groups (cgroups) • 387 Understanding namespace isolation • 390 Understanding kernel capabilities • 391 Hands-on lab – setting a kernel capability • 395 Understanding SECCOMP and system calls • 396 Using process isolation with Docker containers • 397 Sandboxing with Firejail • 398 Hands-on lab – using Firejail • 400 Sandboxing with Snappy • 401 Sandboxing with Flatpak • 405 Summary ����������������������������������������������������������������������������������������������������������������������������� 408 Questions ����������������������������������������������������������������������������������������������������������������������������� 408 Further reading �������������������������������������������������������������������������������������������������������������������� 410 Answers ������������������������������������������������������������������������������������������������������������������������������� 411 Chapter 12: Scanning, Auditing, and Hardening 413 Installing and updating ClamAV and maldet �������������������������������������������������������������������������� 414 Hands-on lab – installing ClamAV and maldet • 415 Table of Contents xvii Hands-on lab – configuring maldet • 416 Updating ClamAV and maldet • 418 Scanning with ClamAV and maldet ���������������������������������������������������������������������������������������� 420 SELinux considerations • 421 Scanning for rootkits with Rootkit Hunter ����������������������������������������������������������������������������� 422 Hands-on lab – installing and updating Rootkit Hunter • 423 Scanning for rootkits • 424 Performing a quick malware analysis with strings and VirusTotal ������������������������������������������� 424 Analyze a file with strings • 425 Scanning the malware with VirusTotal • 426 Understanding the auditd daemon ���������������������������������������������������������������������������������������� 427 Creating audit rules • 428 Auditing a file for changes • 428 Auditing a directory • 430 Auditing system calls • 431 Using ausearch and aureport ������������������������������������������������������������������������������������������������ 432 Searching for file change alerts • 432 Searching for directory access rule violations • 434 Searching for system call rule violations • 439 Generating authentication reports • 441 Using pre-defined rulesets • 442 Hands-on lab – using auditd • 444 Hands-on lab –Using pre-configured rules with auditd • 445 Auditing files and directories with inotifywait ������������������������������������������������������������������������ 446 Applying OpenSCAP policies with oscap �������������������������������������������������������������������������������� 447 Installing OpenSCAP • 447 Viewing the profile files • 448 Getting the missing profiles for Ubuntu • 449 Scanning the system • 449 Remediating the system • 451 Using SCAP Workbench • 453 Choosing an OpenSCAP profile • 455 Applying an OpenSCAP profile during system installation • 456 Summary ����������������������������������������������������������������������������������������������������������������������������� 458 Questions ����������������������������������������������������������������������������������������������������������������������������� 458 Further reading �������������������������������������������������������������������������������������������������������������������� 460 Answers ������������������������������������������������������������������������������������������������������������������������������� 460 xviii Table of Contents Chapter 13: Logging and Log Security 461 Understanding the Linux system log files ������������������������������������������������������������������������������ 461 The system log and the authentication log • 462 The utmp, wtmp, btmp, and lastlog files • 465 Understanding rsyslog ���������������������������������������������������������������������������������������������������������� 467 Understanding rsyslog logging rules • 467 Understanding journald ������������������������������������������������������������������������������������������������������� 469 Making things easier with Logwatch ������������������������������������������������������������������������������������� 472 Hands-on lab – installing Logwatch • 472 Setting up a remote log server ����������������������������������������������������������������������������������������������� 473 Hands-on lab – setting up a basic log server • 474 Creating an encrypted connection to the log server • 475 Creating a stunnel connection on AlmaLinux 9 – server side • 475 Creating a stunnel connection on AlmaLinux – client side • 477 Creating a stunnel connection on Ubuntu – server side • 478 Creating a stunnel connection on Ubuntu – client side • 479 Separating client messages into their own files • 480 Maintaining Logs in Large Enterprises ���������������������������������������������������������������������������������� 481 Summary ����������������������������������������������������������������������������������������������������������������������������� 481 Questions ����������������������������������������������������������������������������������������������������������������������������� 482 Further reading �������������������������ᦙ
|
|||||||||||||||||||||
![]() |
Home » Books and magazines » Computer literature » Mac OS; Linux, FreeBSD and others *NIX |
Current time is: 24-Feb 12:06
All times are UTC + 2
You cannot post new topics in this forum
You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum |