Linux安全加固

Linux安全加固,第1张

概述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 Usersh-4.2# groupmod -g 917 U Centos 7 安全加固(最小化系统安装) 1、锁定无用的账户
sh-4.2# awk -F: {print } /etc/passwd | grep -E -v "root|ftP*" | xargs -n 1 passwd -l

 @H_404_43@ 2、创建普通用户(以普通用户执行系统 *** 作)

sh-4.2# useradd -u 917 Usersh-4.2# groupmod -g 917 User

 @H_404_43@ 3、关闭ssh dns反向解析

sh-4.2# sed -i s:#UsednS no:UsednS no: /etc/ssh/sshd_configsh-4.2# systemctl reload sshd.service

 @H_404_43@ 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.defsPASS_MAX_DAYS   90PASS_MIN_LEN    8

 @H_404_43@ 5、关闭root登录权限

 @H_404_43@   6、设置自动退出时间

sh-4.2# echo "TMOUT=1800" >> /etc/profilesh-4.2# source /etc/profile

 @H_404_43@ 7、关闭linux部分快捷键

sh-4.2# sed -i 1,$ s/^/#/ /usr/lib/systemd/system/ctrl-alt-del.targetsh-4.2# init q

 @H_404_43@ 9、修改文件系统最大打开数

sh-4.2# sed -i $a * soft nofile 65535 /etc/security/limits.confsh-4.2# sed -i $a * hard nofile 65535 /etc/security/limits.confsh-4.2# ulimit -n 65535    # 临时设置

 @H_404_43@ 10、关闭IPV6

sh-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.confsh-4.2# sysctl -p

此内容参考:https://linux.cn/article-4935-1.HTML@H_404_43@

 @H_404_43@ 11、特殊文件权限控制

sh-4.2# chmod 700 /usr/bin/Pingsh-4.2# chmod 700 /usr/bin/whosh-4.2# chmod 700 /usr/bin/w sh-4.2# chmod 700 /usr/bin/whereissh-4.2# chmod 700 /usr/sbin/ifconfigsh-4.2# chmod 700 /usr/bin/gccsh-4.2# chmod 700 /usr/bin/makesh-4.2# chmod 700 /usr/bin/rpmsh-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

 @H_404_43@ 12、开启防火墙

sh-4.2# rpm -qa | grep "firewall" | xargs rpm -e --nodepssh-4.2# yum List iptables*sh-4.2# systemctl start iptablessh-4.2# iptables -Fsh-4.2# iptables -A input -p tcp --dport 22 -j ACCEPTsh-4.2# iptables -A input -j DROPsh-4.2# service iptables save# 这里只是简单的列出基本的iptables规则,主要还是根据自己的业务场景进行设定

 @H_404_43@ 14、系统在线升级 15、升级openssh 总结

以上是内存溢出为你收集整理的Linux安全加固全部内容,希望文章能够帮你解决Linux安全加固所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1031131.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存