#设定用户90天修改密码, 7 days in advance reminder userlist=$ (ls /home/|awk ' {print $NF} ' |grep -v lost+found) for user in $UserListdo chage -m 90 -W 7 $userdone # Forbidden pingecho 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all# Set user Expiration time 90 default password length 8 bit cp /etc/login.defs /etc/login.defs.baksed -i '/pass_min_len/s/[0-9]\{1,6 \}/90/' /etc/login.defssed -i '/pass_min_len/s/[0-9]\{1,3\}/8/' /etc/login.defs# set user login, Normal User login identification more than 6 lock 300s.echo "account required pam_tally2.so deny=100 no_magic_root Reset " >>/etc/pam.d/system-authecho " Auth required pam_tally2.so onerr=fail deny=6 unlock_time=300 " >>/etc/pam.d/system-auth# hidden system version number mv /etc/issue /etc/ isseumv /etc/issue.net /etc/isseu.netmv /etc/redhat-release /etc/rehdat-release# Optimize configuration parameters. echo ' # kernel Sysctl configuration file for red hat linux## for binary values, 0 is disabled, 1 is enabled. see sysctl (8) and# Sysctl.conf (5) for more details.# controls ip packet forwardingnet.ipv4.ip_ Forward = 0# controls source route verificationnet.ipv4.conf.default.rp_filter = 1# do not accept source routingnet.ipv4.conf.default.accept_source_route = 0# controls the system request debugging functionality of the kernelkernel.sysrq = 0# controls whether core dumps will append the pid to the core filename# useful for debugging multi-threaded applicationskernel.core_uses_pid = 1# controls the use of tcp syncookiesnet.ipv4.tcp_syncookies = 1# controls the maximum size of a Message, in byteskernel.msgmnb = 65536# controls the default maxmimum size of a mesage queuekernel.msgmax = 65536# Controls the maximum shared segment size, in byteskernel.shmmax = 68719476736# controls the maximum number of shared memory segments, in pageskernel.shmall = 4294967296# ------------- Kernel Optimization ------------- net.ipv4.tcp_max_tw_buckets = 60000net.ipv4.tcp_sack = 1net.ipv4.tcp_window_scaling = 1net.ipv4.tcp_rmem = 4096 87380 4194304net.ipv4.tcp_wmem = 4096 16384 4194304net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_ Max = 16777216net.core.wmem_max = 16777216net.core.netdev_max_backlog = 262144net.core.somaxconn = 262144net.ipv4.tcp_max_orphans = 3276800net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_ timestamps = 0net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_mem = 94500000 915000000 927000000net.ipv4.tcp_fin_timeout = 1net.ipv4.tcp_keepalive_time = 30net.ipv4.ip_local_port_range = 1024 65000net.ipv4.ip_conntrack_max = 655360net.ipv4.netfilter.ip_conntrack_max =655360net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180 ' >/etc/sysctl.conf# effective sysctl -p# record histtory log echo ' #history export histtimeformat= "%f %t ' WhoAmI ' " user_ip= ' who -u am i 2>/dev/ null| awk ' {print $NF} ' |sed -e ' s/[()]//g ' histdir=/usr/local/bin/.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 "chmod 600 $HISTDIR/${logname}/*.history* 2>/dev/null ' >>/etc/profile# secure login/etc/ Hosts.allow## hosts.allow this file describes the names of the hosts which are# allowed to use the local inet services, as decided# by the '/USR/SBIN/TCPD ' server.## #vpnsshd: 111.1.1.1sshd:122.1.1.2# #jumpsshd:10.0.1.1/etc/hosts.deny## hosts.deny this file describes the names of the hosts which are# *not* allowed to use the local INET services, as decided# by the '/USR/SBIN/TCPD ' Server.## the portmap line is redundant, but it is left to remind you that# the new secure portmap uses hosts.deny and hosts.allow. in particular# you should know that nfs uses portmap!sshd:all# Check firewall configuration (open specified user address login | Service address open user address segment) iptables-save# Create a normal user useradd liangxiujunecho -e ' xx123456 ' |passwd liangxiujun --stdin# Disable root login rights sed -i ' s/#PermitRootLogin yes/permitrootlogin no /g ' /etc/ssh/sshd_config# optimized ssh link slow problem sed -i ' s/gssapiauthentication yes/gssapiauthentication no/' /etc/ssh/sshd_configsed -i '/#UseDNS yes/a\usedns no ' /etc/ssh/sshd_ Config/etc/init.d/sshd restart
This article from "Born for Technology" blog, reproduced please contact the author!
Some details of system security