


This article mainly introduces the relevant information summarized by the three methods of strengthening the Linux system. Through this article, I hope you can master this part of the content. Friends in need can refer to
Strengthening the Linux system Summary of three methods
Linux command line history reinforcement
Record the commands executed by the user on the command line by configuring system environment variables.
vim /etc/profile.d/system_monitor.sh # 添加下面代码 export TMOUT=600 readonly TMOUT #history USER_IP=`who -u am i 2>/dev/null | awk '{print $NF}' | sed -e 's/[()]//g'` HISTDIR=/usr/share/.history if [ -z $USER_IP ]; then USER_IP=`hostname` fi if [ ! -d $HISTDIR ]; then mkdir -p $HISTDIR chmod 777 $HISTDIR fi if [ ! -d $HISTDIR/${LOGNAME} ]; then mkdir -p $HISTDIR/${LOGNAME} chmod 300 $HISTDIR/${LOGNAME} fi export HISTSIZE=4000 DT=`date +%Y%m%d_%H%M%S` export HISTFILE="$HISTDIR/${LOGNAME}/${USER_IP}.history.$DT" export HISTTIMEFORMAT="[%Y.%m.%d %H:%M:%S]" chmod 600 $HISTFILE/${LOGNAME}/*.history* 2>/dev/null
Reload environment variables
source /etc/profile.d/system_monitor.sh
Effect: Each account’s login IP and running commands will be The records in this directory are as follows:
[root@localhost ~]# ll /usr/share/.history/root/ total 8 -rw-------. 1 root root 236 Apr 23 21:49 1.180.212.137.history.20170423_214918 -rw-------. 1 root root 564 Apr 23 21:54 1.180.212.137.history.20170423_214957
crond calls the black and white list
Cron has its own built-in feature, which allows Define who can and cannot run tasks. This is controlled through two files /etc/cron.allow and /etc/cron.deny. To lock users who use Cron, you can simply write their names in corn.deny, and to allow users to run cron, add their names to cron.allow. If you want to ban all users, only allow root user. As follows:
# echo 'root' >> /etc/cron.allow # echo 'ALL' >> /etc/cron.deny
ssh service prohibits root login
1. Do not use the default port, modify the method;
Port 3714
2. Do not use the first version of the protocol;
Protocol 2
3. Limit the users who can log in;
AllowUsers user1 user2 #仅允许user1和user2用户登录
4. Set the idle session timeout;
5. Use the firewall to set the ssh remote access policy; only allow access from hosts in the specified network;
6. Only listen on the specified IP address;
ListenAddress
7. When based on password authentication, use a strong password policy;
# 使用mkpasswd命令生成密码; mkpasswd -l 15 -s 3 -d 3 -C 3
8. Finally, use key-based authentication
9. Prohibit the use of empty passwords, enabled by default;
PermitEmptyPasswords no:是否允许空密码登录;
10. Prohibit management Log in directly;
PermitRootLogin yes # 是否允许管理员直接登录;安全起见,建议为no;
11. Limit ssh access frequency and concurrent online;
12.Do log analysis;
The above is the detailed content of Introduction to Linux system hardening methods. For more information, please follow other related articles on the PHP Chinese website!

The reason for mastering Linux operations is its wide range of application scenarios and powerful functions. 1) Linux is suitable for developers, system administrators and technology enthusiasts, and is used in server management, embedded systems and containerization technologies. 2) Learning Linux can start with file system structure, shell usage, user permission management and process management. 3) The Linux command line is its core tool, which executes commands through the shell, such as ls, mkdir, cd, etc., and supports redirection and pipeline operations. 4) Advanced usage includes writing automated scripts, such as backup scripts, using tar commands and conditional judgments. 5) Common errors include permissions, paths and syntax issues, which can be debugged through echo, set-x and $?. 6) Performance optimization suggestions

The five pillars of the Linux system are: 1. Kernel, 2. System library, 3. Shell, 4. File system, 5. System tools. The kernel manages hardware resources and provides basic services; the system library provides precompiled functions for applications; the shell is the interface for users to interact with the system; the file system organizes and stores data; and system tools are used for system management and maintenance.

In Linux systems, maintenance mode can be entered by pressing a specific key at startup or using a command such as "sudosystemctlrescue". Maintenance mode allows administrators to perform system maintenance and troubleshooting without interference, such as repairing file systems, resetting passwords, patching security vulnerabilities, etc.

Linux beginners should master basic operations such as file management, user management and network configuration. 1) File management: Use mkdir, touch, ls, rm, mv, and CP commands. 2) User management: Use useradd, passwd, userdel, and usermod commands. 3) Network configuration: Use ifconfig, echo, and ufw commands. These operations are the basis of Linux system management, and mastering them can effectively manage the system.

The article explains how to manage sudo privileges in Linux, including granting, revoking, and best practices for security. Key focus is on editing /etc/sudoers safely and limiting access.Character count: 159

The article provides a guide on setting up two-factor authentication (2FA) for SSH on Linux using Google Authenticator, detailing installation, configuration, and troubleshooting steps. It highlights the security benefits of 2FA, such as enhanced sec

The article discusses using top, htop, and vmstat for monitoring Linux system performance, detailing their unique features and customization options for effective system management.

Article discusses managing software packages in Linux using apt, yum, and dnf, covering installation, updates, and removals. It compares their functionalities and suitability for different distributions.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download
The most popular open source editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),