First, account security Control account security Basic measures 1, System account cleanup
- Set the shell of a non-logged-on user to/sbin/nologin
Useradd–s/sbin/nologinusermod-s
- lock out long-term unused accounts
Passwd–lpasswd-u
- Delete unused accounts
Userdel-r
- Lock account file passwd, shadow
[[Email protected]~]# chattr +i/etc/passwd/etc/shadow[[email protected]~]# lsattr/etc/passwd/etc/shadow \ \ Lock file and view status- ---i-------e-/etc/passwd----i-------e-/etc/shadow [[email protected] ~]# chattr-i/etc/passwd/etc/shadow[[email Protected] ~]# Lsattr/etc/passwd/etc/shadow//unlock file and view status------------E-/etc/passwd------------e-/etc/shadow
2. Password Security control
- Set Password validity period
Useradd-e
- require user to change password at next logon
[Email protected]~]# vi/etc/login.defs//apply to new user ... Pass_max_days 30[[email protected]~]# chage-m Lisi//apply to existing users [[email protected] ~]# chage-d 0 zhangsan//force the next login Change Password when
3. Command history limit
- reduce the number of command bars recorded
[Email protected]~]# vi/etc/profile ... histsize=200
- automatically empty command history when logging off
[Email protected]~]# VI ~/.bash_logout......history-cclear
4. Automatic logout of terminal
- automatic logoff after 600 seconds of inactivity
[Email protected] ~]# VI ~/.bash_profile......export tmout=600
5. Switch users with the SU command
Use and usage
Purpose: Substitute user, switch users
Format: Su-target user
-Restrict users who use the SU command
-Enable Pam_wheel authentication module
[Email protected]~]# vi/etc/pam.d/su #%pam-1.0auth sufficient Pam_rootok.soauth required pam_wheel.so Use_uid
--Allow users with the SU command to join the wheel group
[[email protected] ~]# gpasswd-a Tsengyia Wheeltsengyia is adding user "Tsengyia" to the "wheel" group
6. Use the sudo mechanism to elevate permissions
Purpose: A command that performs authorization as another user (such as root)
Usage:sudo authorization command
-Configure sudo authorization
Visudo or Vi/etc/sudoers
Record format: list of user host names = command program
[Email protected]~]# visudo......%wheel All=nopasswd:alljerry Localhost=/sbin/ifconfigsyrianer Localhost=/sbin/*,!/sbin/ifconfig,!/sbin/route//You can use wildcard characters *, Take back symbols! Cmnd_alias Pkgtools=/bin/rpm,/usr/bin/yum//Similar aliases include: User_alias, Host_aliasmike Localhost=pkgtools
Second, system boot and Login control 1, switch machine safety control
- Adjust BIOS boot settings
--Set the first boot device as the drive of the current system
--prohibit booting the system from other devices (CD, USB, Network)
--Set the security level to setup and the Administrator password
- Disable Restart hotkey Ctrl+alt+del
[Email protected]~]# vi/etc/init/control-alt-delete.conf ... #starton control-alt-delete #exec/sbin/shutdown-r Now " Control-alt-delete pressed "[[Email protected]~]# reboot
-grub Implementation of limitations
Using Grub-md5-crypt to get an encrypted string
Modify the grub.conf file to add a password record
[Email protected]~]# grub-md5-cryptpassword:retypepassword://Repeat password $1$kndw50$wrw2w1v/jbz8n5q2fon4y/
[Email protected] ~]# vi/boot/grub/grub.conf ...//Add to 1th title password--md5 $1$kndw50$wrw2w1v/jbz8n5q2fon4y/title Red Hat Enterprise Linux (2.6.32-431.el6.x86_64)
2. Terminal login Security Control
- Reduce the number of open terminals
[Email protected]~]# vi/etc/init/start-ttys.conf ...//Omit part of content envactive_consoles=/dev/tty[456]//Disable three terminals: Tty1, Tty2, Tty3[[email protected]~]# vi/etc/sysconfig/init ...//omit some content Active_consoles=/dev/tty[456][[email protected]~]# reboot
- Restrict root login only at secure terminal
Secure terminal configuration:/etc/securetty
[Email protected]~]# vi/etc/securetty ... tty1tty2tty3tty4#tty5#tty6
Disable root user login from terminal tty5, Tty6
- prohibit normal user login
--Build/etc/nologin file
--Restore normal after deleting nologin files or rebooting
[[Email protected]~]# touch/etc/nologin//Prohibit normal user login [] [email protected]~]# rm-rf/etc/nologin//cancellation of the above login restrictions
Third, password detection, port scan 1, System weak password detection
Joth the Ripper, referred to as JR
A password analysis tool that supports dictionary-style brute force
Password analysis can be used to detect the strength of the shadow file.
Official website: http://www.openwall.com/john/
Installing the JR Tool
Make Clean System type
The main program file is John
[Email protected]~]# tar zxf john-1.7.8.tar.gz[[email protected]~]# cd john-1.7.8/src[[email protected]]# make clean lin Ux-x86-64 ... [Email protected]]# ls. /run/john. /run/john
Detecting Weak password accounts
--Get the shadow file for the Linux/unix server
--Execute the John program and use the shadow file as a parameter
Password file for brute force hack
--Prepare the password dictionary file, default to Password.lst.
--Execute the John program, combined with the--wordlist= dictionary file
2. Network Port Scan
The scanning syntax of NMAP
Nmap [Scan type] [options] < scan target ...>
Common types of scans
-ss,tcp SYN Scan (half-on)-ST,TCP connection scan (full open)-sf,tcp fin scan-su,udp scan-sp,icmp scan-p0, skip ping detect-P port number
This article is from the "Jackeyge" blog, make sure to keep this source http://jackeyge.blog.51cto.com/12241288/1881500
centos6.5 System Reinforcement