Linux安全加固
发布时间:2020-12-14 01:59:50 所属栏目:Linux 来源:网络整理
导读:Centos 7 安全加固(最小化系统安装) 1、锁定无用的账户 sh - 4.2 # awk -F: ‘ {print $1} ‘ /etc/ passwd | grep -E -v " root|ftp* " | xargs -n 1 passwd -l ? 2、创建普通用户(以普通用户执行系统操作) sh - 4.2 # useradd -u 917 User sh - 4.2 #
Centos 7 安全加固(最小化系统安装)1、锁定无用的账户sh-4.2# awk -F: ‘{print $1}‘ /etc/passwd | grep -E -v "root|ftp*" | xargs -n 1 passwd -l ? 2、创建普通用户(以普通用户执行系统操作)sh-4.2# useradd -u 917 User sh-4.2# groupmod -g 917 User ? 3、关闭ssh dns反向解析sh-4.2# sed -i ‘s:#UseDNS no:UseDNS no:‘ /etc/ssh/sshd_config sh-4.2# systemctl reload sshd.service ? 4、设置密码最大有效周期sh-4.2# chage -d 0 User # 初次登录必须更改密码 sh-4.2# chage -M 90 -m 7 -W 7 User #用户90天后密码过期,至少7天后才能修改密码,密码过期前7天开始收到告警信息 sh-4.2# vi /etc/login.defs PASS_MAX_DAYS 90 PASS_MIN_LEN 8 ? 5、关闭root登录权限? ?6、设置自动退出时间sh-4.2# echo "TMOUT=1800" >> /etc/profile sh-4.2# source /etc/profile ? 7、关闭linux部分快捷键sh-4.2# sed -i ‘1,$ s/^/#/‘ /usr/lib/systemd/system/ctrl-alt-del.target sh-4.2# init q ? 9、修改文件系统最大打开数sh-4.2# sed -i ‘$a * soft nofile 65535‘ /etc/security/limits.conf sh-4.2# sed -i ‘$a * hard nofile 65535‘ /etc/security/limits.conf sh-4.2# ulimit -n 65535 # 临时设置 ? 10、关闭IPV6sh-4.2# sed -i ‘$a net.ipv6.conf.all.disable_ipv6 = 1‘ /etc/sysctl.conf sh-4.2# sed -i ‘$a net.ipv6.conf.default.disable_ipv6 = 1‘ /etc/sysctl.conf sh-4.2# sysctl -p 此内容参考:https://linux.cn/article-4935-1.html ? 11、特殊文件权限控制sh-4.2# chmod 700 /usr/bin/ping sh-4.2# chmod 700 /usr/bin/who sh-4.2# chmod 700 /usr/bin/w sh-4.2# chmod 700 /usr/bin/whereis sh-4.2# chmod 700 /usr/sbin/ifconfig sh-4.2# chmod 700 /usr/bin/gcc sh-4.2# chmod 700 /usr/bin/make sh-4.2# chmod 700 /usr/bin/rpm sh-4.2# chattr +i /etc/passwd sh-4.2# chattr +i /etc/shadow sh-4.2# chattr +i /etc/group sh-4.2# chattr +i /etc/gshadow sh-4.2# chattr +a /root/.bash_history sh-4.2# chattr +i /root/.bash_history ? 12、开启防火墙sh-4.2# rpm -qa | grep "firewall" | xargs rpm -e --nodeps sh-4.2# yum list iptables* sh-4.2# systemctl start iptables sh-4.2# iptables -F sh-4.2# iptables -A INPUT -p tcp --dport 22 -j ACCEPT sh-4.2# iptables -A INPUT -j DROP sh-4.2# service iptables save # 这里只是简单的列出基本的iptables规则,主要还是根据自己的业务场景进行设定 ? 14、系统在线升级15、升级openssh(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |