User Management user permission 1) restrict the password policy echo & quot; Passwordsexpireevery180days & quot; perl-npe & #39; s/PASS_MAX_DAYS \ s + 99999/pass_max_days-1/& amp; #39;-I/etc/l user management
User permissions
1) restrict root
Echo "tty1">/etc/securetty
Chmod 700/root
2) password policy
Echo "Passwords expire every 180 days"
Perl-npe's/PASS_MAX_DAYS \ s + 99999/PASS_MAX_DAYS 180/'-I/etc/login. defs
Echo "Passwords may only be changed once a day"
Perl-npe's/PASS_MIN_DAYS \ s + 0/PASS_MIN_DAYS 1/g'-I/etc/login. defs
Use sha512 to protect passwords instead of md5
Authconfig -- passalgo = sha512 -- update
3) umask restrictions
Change umask to 077
Perl-npe's/umask \ s + 0 \ d2/umask 077/g'-I/etc/bashrc
Perl-npe's/umask \ s + 0 \ d2/umask 077/g'-I/etc/csh. cshrc
4) modify Pam
Touch/var/log/tallylog
Cat <'eof '>/etc/pam. d/system-auth
# % PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
Auth required pam_env.so
Auth sufficient pam_unix.so nullok try_first_pass
Auth requisite pam_succeed_if.so uid >=500 quiet
Auth required pam_deny.so
Auth required pam_tally2.so deny = 3 onerr = fail unlock_time = 60
Account required pam_unix.so
Account sufficient pam_succeed_if.so uid <500 quiet
Account required pam_permit.so
Account required pam_tally2.so per_user
Password requisite pam_cracklib.so try_first_pass retry = 3 minlen = 9 lcredit =-2 ucredit =-2 dcredit =-2 ocredit =-2
Password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok remember = 10
Password required pam_deny.so
Session optional pam_keyinit.so revoke
Session required pam_limits.so
Session [success = 1 default = ignore] pam_succeed_if.so service in crond quiet use_uid
Session required pam_unix.so
EOF
/Var/log/tallylog is a binary log that records authentication failures. Can I use pam_tally2? Reset-u username unlock
5) reclaim idle users
Echo "Idle users will be removed after 15 minutes"
Echo "readonly TMOUT = 900">/etc/profile. d/os-security.sh
Echo "readonly HISTFILE"> & gt;/etc/profile. d/os-security.sh
Chmod + x/etc/profile. d/os-security.sh
6) cron and at restrictions
Echo "Locking down Cron"
Touch/etc/cron. allow
Chmod 600/etc/cron. allow
Awk-F: '{print $1}'/etc/passwd | grep-v root>/etc/cron. deny
Echo "Locking down"
Touch/etc/at. allow
Chmod 600/etc/at. allow
Awk-F: '{print $1}'/etc/passwd | grep-v root>/etc/at. deny
Delete special users and groups in the system
Userdel username
Userdel adm
Userdel lp
Userdel sync
Userdel shutdown
Userdel halt
Userdel news
Userdel uuucp
Userdel operator
Userdel games
Userdel gopher
The deleted users are created by default by the system, but some accounts are not used in common servers. However, these accounts are often used and attacked by hackers.
Groupdel username
Groupdel adm
Groupdel lp
Groupdel news
Groupdel uuucp
Groupdel games
Groupdel dip
Similarly, the group accounts created by default for system installation are deleted. This reduces the chances of being attacked.
Service Management
Disable services not used by the system
Chkconfig level 35 apmd off
Chkconfig level 35 netfs off
Chkconfig level 35 yppasswdd off
Chkconfig level 35 ypserv off
Chkconfig level 35 dhcpd off?
Chkconfig level 35 portmap off
Chkconfig level 35 lpd off
Chkconfig level 35 nfs off
Chkconfig level 35 sendmail off
Chkconfig level 35 snmpd off
Chkconfig level 35 rstatd off
Chkconfig level 35 atd off ??
Regularly update the system
Yum-y update, which can be added to the cron job.
Ssh service security
Use a certificate to log on to the system, not detailed, please refer to this article http://www.centos.bz/2012/02/strengthen-ssh-security-login-with-certificate/
LAMP security
System File permission
Modify the execution permission of the init directory file
Chmod-R 700/etc/init. d /*
Modify SUID and SGID permissions for some system files
Chmod a-s/usr/bin/chage
Chmod a-s/usr/bin/gpasswd
Chmod a-s/usr/bin/wall
Chmod a-s/usr/bin/chfn
Chmod a-s/usr/bin/chsh
Chmod a-s/usr/bin/newgrp
Chmod a-s/usr/bin/write
Chmod a-s/usr/sbin/usernetctl
Chmod a-s/usr/sbin/traceroute
Chmod a-s/bin/mount
Chmod a-s/bin/umount
Chmod a-s/bin/ping
Chmod a-s/sbin/netreport
Modify the system boot file
Chmod 600/etc/grub. conf
Chattr + I/etc/grub. conf
Log Management
1. system boot log
Dmesg
You can use the dmesg command to quickly view the boot log of the last system boot. Usually it has a lot of content, so you often want to transmit it to a reader through a pipeline.
2. system operation logs
A. Linux logs are stored in the/var/log directory.
There are several log files maintained by the system, but other services and programs may also put their logs here. Most logs can only be read by the root user. However, you only need to modify the file access permission to allow others to read the logs.
The names of common system log files and their descriptions are as follows:
Lastlog records the last successful logon time of the user.
Poor loginlog logon attempt records?
Messages records messages output to the system console and generated by syslog system service programs
Utmp records each user Currently logged on
Utmpx extended utmp
Wtmp records the historical information of each user logon and logout. wtmpx expanded wtmp
Vold. log records errors with external media
Xferkig records Ftp access sulog records su command usage
Acct records commands used by each user
Aculog outbound automatic call record
B./var/log/messages
Messages logs are core system log files. It contains boot messages when the system is started and other status messages when the system is running. IO errors, network errors, and other system errors are recorded in this file. Other information, such as switching a person's identity to root, is also listed here. If the service is running, such as a DHCP server, you can observe its activity in the messages file. In general,/var/log/messages is the file you need to view before troubleshooting.
C./var/log/XFree86.0.log
This log records the last execution result of Xfree86 Xwindows server. If you encounter a problem when starting to the graphic mode, you can find the cause of the failure from this file.
Network security
Use TCP_WRAPPERS
Using TCP_WRAPPERS can protect your system against external intrusion. The best policy is to stop all
Host (in "/etc/hosts. add "ALL: ALL @ ALL, PARANOID" to the deny file, and then add "/etc/hosts. add the list of allowed hosts to the allow file.
Step 1:
Edit the hosts. deny File (vi/etc/hosts. deny) and add the following line:
# Deny access to everyone.
ALL: ALL @ ALL, PARANOID
This indicates that all services and addresses are blocked unless the address package is in the list of hosts allowed to access.
Step 2:
Edit the hosts. allow file (vi/etc/hosts. allow) and add the list of hosts allowed to access.
For example:
Ftp: 202.54.15.99 foo.com
202.54.15.99 and foo.com are IP addresses and host names that allow access to the ftp service.
Step 3:
The tcpdchk program is the tepd wrapper setting check program. It is used to check your tcp wrapper settings and report potential and real problems found. After setting, run the following command:
[Root @ kapil/] # tcpdchk
Use iptables firewall
For more information, see:
1. iptables rules suitable for Web servers
2. iptables detailed tutorial