Article Title: Linux system security reinforcement. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
I. Installation and upgrade
Use custom installation of M. Do not install unnecessary software packages. If necessary, add password restrictions to the lilo/grub boot tool. After installation, use up2date, yum, or apt (Debian) upgrading System Software is sometimes necessary to upgrade the kernel.
Edit/etc/sudoers to add the following content
Jinshuai ALL = NOPASSWD: ALL
Ii. Account Security
1. Generally, servers are stored in IDCs and need to be managed through remote access. To Restrict root remote access, the administrator can log on remotely through a common account and then su to root, developers only use common account permissions.
1) Add a setting command in the/etc/default/login file:
CONSOLE =/dev/tty01
2) You can use the following script to disable access to the console:
#! /Bin/sh
Cd/etc/pam. d
For I in *; do
Sed '/[^ #]. * pam_console.so/s/^/#/' foo & mv foo $ I
Done
3) The following measures can be used to prevent anyone from su as root and add the following two lines to/etc/pam. d/su.
Auth sufficient/lib/security/$ ISA/pam_rootok.so debug
Auth required/lib/security/$ ISA/pam_wheel.so group = wheel
Then, put the user you want to execute su as root into the wheel group:
Usermod-G10 admin
2. edit/etc/securetty, comment out all the consoles that allow remote root logon, and disable all console programs. The command is as follows:
Rm-f/etc/security/console. apps/servicename
3. Use the minimum service principle and comment out unnecessary services. In/etc/inetd. add "#" to the service that is not required in conf. In later versions, inetd is not available, but Xinetd is replaced. Cancel the automatic start of the service and set/etc/rc. in d/rc3.d, the first letter of the service that does not need to be run is "S" changed to "K", and other services remain unchanged.
Iv. File System Permissions
1) Find out all programs with "s" bits in the system, remove unnecessary "s" bits, or delete unnecessary ones directly, in this way, you can avoid abuse and elevation of permissions. The command is as follows:
Find/-type f-perm-4000-o-perm-2000-print | xargs ls-lg
2) add important files with unchangeable attributes (this is generally not required ):
Chattr + I/etc/passwd
Immutable, the system does not allow any modifications to this file. If the directory has this attribute, any process can only modify the files under the Directory and cannot create or delete files.
3) Find out files without a master in the system:
Find/-nouser-o-nogroup
4) find any file or directory with write permission:
Find/-type f-perm-2-o-perm-20 | xagrs ls-lg
Find/-type d-perm-2-o-perm-20 | xagrs ls-ldg
5) the ftp upload directory cannot grant execution permissions. For example, additional security configurations should be made to provide CGI-enabled virtual host services. compile/etc/security/limits. conf, add or change the following lines:
Hard core 0
Hard rss 5000
Hard nproc 20
5. Banner disguise
1) intruders usually attack through the operating system, service, and application versions. The oil leak list and attack process are also classified based on this. Therefore, it is necessary to make some effort to increase the difficulty of intrusion.
So edit/etc/rc. d/rc. local as follows:
Echo "Kernel $ (uname-r) on $ a $ (uname-m)">/etc/issue
Echo "Kernel \ r on an \ m">/etc/issue
Cp-f/etc/issue/etc/issue.net
Echo>/etc/issue
2) In the Apache configuration file, find the "ServerTokens" and "ServerSignature" ve, modify the default attributes as follows, and use the "no echo version number:
ServerTokens prod
ServerSignature Off
6. IPTABLES firewall rules:
Iptables-a input-p -- dport 22-j ACCEPT
Iptables-a input-I eth0-p tcp -- dport 80-j ACCEPT
Iptables-a input-m state -- state ESTABLISHED, RELATED-j ACCEPT
Iptables-a input-j DROP
The above rules will prevent the active TCP selection from the inside out. The above is a simple example. The IPTABLES function is very powerful and you can set firewall rules based on the actual situation.
VII. tripwire is a famous tool,It helps you determine whether important system files have been modified. Currently, Linux releases generally have open-source versions with the tool. You can add some sensitive files to the default validation object configuration file.
8. Self-Scan
General security reinforcement is basically done. We can make a risk assessment by ourselves. We recommend using nessus latest version.
9. Log Policy
It is mainly to create a hard copy of important logs related to human intrusion, not even the last black box in the emergency response. You can redirect them to printers, Administrator emails, independent log servers, and their hot backups.
10. Snort intrusion detection system
This is necessary for systems with high requirements for human intrusion response and security logs. For general systems, if the administrator simply does not read a large number of logs, it will occupy system resources in vain, just like the chicken ribs.
The following suggestions are provided to prevent viruses on the Linux platform for reference only:
(1) reinforce the system.
(2) Pay attention to Security announcements and promptly fix vulnerabilities.
(3) do not use the root permission for routine operations.
(4) do not install any drivers of unknown devices.
(5) do not run executable programs or scripts with unknown origins on important servers.
(6) Install antivirus software whenever possible and regularly upgrade the virus code base.
(7) For Linux servers connected to the Internet, check whether Linux viruses, worms, and Trojans exist on a regular basis.
(8) For Linux servers that provide file services, it is best to deploy a software that can simultaneously scan and kill Windows and Linux viruses.
(9) For Linux servers that provide mail services, it is best to use an e-mail virus scanner.
All in all, you must take multiple measures to prevent viruses on the Linux platform.