Linux安全加固脚本的示例分析
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,今天就跟大家聊聊有关Linux安全加固脚本的示例分析,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。#安全加固脚本#!/bin/bash #ve
千家信息网最后更新 2025年12月02日Linux安全加固脚本的示例分析
今天就跟大家聊聊有关Linux安全加固脚本的示例分析,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
#安全加固脚本#!/bin/bash #version1.0;write at 2017-03-29;#write by Ringoo; #1.将root管理员名称修改为Ringoouseradd -u 0 -g 0 -o ringoouseradd pso #2.修改默认密码策略#备份文件cp /etc/login.defs /etc/login.defs.baksed -i 's/99999/90/' /etc/login.defs #3.设置3次输错密码锁定用户#备份文件cp /etc/pam.d/system-auth /etc/pam.d/system-auth.baksed -e '5 i\auth required /lib64/security/pam_tally2.so deny=3 unlock_time=300' -i /etc/pam.d/system-auth#密码复杂度设置sed -e "14 i\password requisite pam_cracklib.so minlen=10 difok=3 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 try_first_pass retry=3" -i /etc/pam.d/system-authsed -e '15d' -i /etc/pam.d/system-auth #修改/etc/profile#备份文件cp /etc/profile /etc/profile.baksed -e 's/HISTSIZE=1000/HISTSIZE=3000/' -i /etc/profilesed -i "/HISTSIZE=3000/a HISTTIMEFORMAT=\"%F %T \"" /etc/profilesed -i "/HISTSIZE=3000/a TMOUT=1800" /etc/profilesed -i "$ a\export HISTORY_FILE=/var/log/useraudit.log" /etc/profilesed -i "$ a\export PROMPT_COMMAND=\'{ h=\`history 1\`;w=\`who am i\`;echo -e \$(date \"+%Y-%m-%d %H:%M:%S\") --- \$w ---\$h;} >> \$HISTORY_FILE\'" /etc/profile /bin/touch /var/log/useraudit.log/bin/chmod 777 /var/log/useraudit.log/usr/bin/chattr +a /var/log/useraudit.log #修改sshd配置#备份文件cp /etc/ssh/sshd_config /etc/ssh/sshd_config.baksed -e 's/\#PermitRootLogin yes/PermitRootLogin no/' -i /etc/ssh/sshd_configsed -e 's/\#Port 22/Port 2222/' -i /etc/ssh/sshd_configsed -e 's/\#UseDNS yes/UseDNS no/' -i /etc/ssh/sshd_configsed -e 's/X11Forwarding yes/X11Forwarding no/' -i /etc/ssh/sshd_configsed -e 's/GSSAPIAuthentication yes/\#GSSAPIAuthentication yes/' -i /etc/ssh/sshd_configsed -e 's/GSSAPICleanupCredentials yes/\#GSSAPICleanupCredentials yes/' -i /etc/ssh/sshd_config#/etc/init.d/sshd restart #禁用不需要的服务/sbin/chkconfig ip6tables off/sbin/chkconfig iptables off/sbin/chkconfig avahi-daemon off/sbin/chkconfig avahi-dnsconfd off #数据库服务器这里请酌情配置#备份文件#cp /etc/pam.d/login /etc/pam.d/login.bak#cp /etc/security/limits.conf /etc/security/limits.conf.bak#sed -i "$ a\session required /lib64/security/pam_limits.so" /etc/pam.d/login#sed -i "$ a\* soft nofile 65535" /etc/security/limits.conf#sed -i "$ a\* hard nofile 65535" /etc/security/limits.conf echo "please restart the server for the settings to take effect,press enter exit" read pauseexit 1看完上述内容,你们对Linux安全加固脚本的示例分析有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。
备份
文件
安全
脚本
加固
内容
密码
示例
分析
服务
配置
复杂
名称
复杂度
数据
数据库
更多
服务器
用户
知识
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
什么是我国网络安全的基本发
服务器拒绝访问
asp.net和数据库
河北线上医疗系统软件开发
网络安全证书存在错误
苏州常见软件开发售后服务
涉及海量数据库的案例
励志软件开发工具
恋爱请响铃的软件开发者是谁
戴尔2950服务器光盘
瑜伽软件开发
网络安全治理是
数据库文件传到u盘
英语网络安全建议句子
美国对于服务器的管理制度
字节网络安全薪资
材料测试技术数据库
云丁网络技术有多少人
360网络安全
阿里云数据库技术专家
网络安全我来守护
初中学软件开发好吗
软件开发培训学校觅语
落实网络安全责任实施细则
我的世界服务器变成动物指令
重庆网站服务器租用云主机
黑客学网络技术
SEE板块经济数据库
网络技术可以考专升本吗
悠久之树服务器错误500