惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
Spread Privacy
Spread Privacy
Cloudbric
Cloudbric
V
Vulnerabilities – Threatpost
博客园 - 叶小钗
I
Intezer
S
Secure Thoughts
Jina AI
Jina AI
T
Tenable Blog
博客园 - 【当耐特】
WordPress大学
WordPress大学
W
WeLiveSecurity
宝玉的分享
宝玉的分享
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Google DeepMind News
Google DeepMind News
Schneier on Security
Schneier on Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
Martin Fowler
Martin Fowler
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
IT之家
IT之家
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
V
Visual Studio Blog
S
Securelist
M
MIT News - Artificial intelligence
H
Help Net Security
Scott Helme
Scott Helme
N
News and Events Feed by Topic
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园_首页
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
T
Tailwind CSS Blog
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog
S
Security @ Cisco Blogs
大猫的无限游戏
大猫的无限游戏
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
H
Heimdal Security Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale

博客园 - lsgxeva

RK3588 firefly net n2n config OpenWrt 集成 openNDS 进行 强制门户(Captive Portal) 认证 OpenWrt 集成 easycwmpd 成为 TR-069协议中的设备端(CPE) eh.h acu100 bridge vlan config 卫星天线(KA 0.85m 4W_BUC)使用 SatBox331-20 Modem 的性能情况 OpenSpec OPSX 完整指南 Claude Skill Creator 2.0 完整上手攻略 Auto-Memory + CLAUDE.md Conductor 完整上手攻略 GitNexus 完整上手攻略 code-review-graph 完整上手攻略 Claude Code Hooks 完整开发者指南 Openwrt switch vlan配置 llm-course Claude Code 入门教程 MT5专业交易面板 routeros RB750GR3 配置双WAN口 Quectel Modem Wiki sdxlemur 高通5G平台(SDX55\SDX62\SDX65):ping包异常问题排查指南 - lsgxeva - 博客园 高通SDX62平台 MBIM搜网、查询信号等功能异常 Win11数字许可证激活 BirdSat VS100K info wireshark筛选语句详解 windows基线整改方法 NanoPi_R5C ArcBox Config win10远程桌面其他电脑出现如下错误,由于数据加密错误,这个会话讲结束,请重新连接到远程计算机 如何评价杨立昆认为大模型只是对海量文本的模式进行复杂拟合,根本不懂意义? IQ200Board default access problem Win10 输入法卡顿 adaptive_relaxed_optimized 如何下载安装App Store应用旧版本教程 小米澎湃OS 关闭广告 Scrum 模型
linux基线整改方法
lsgxeva · 2026-03-06 · via 博客园 - lsgxeva

linux基线整改方法

来源 https://mp.weixin.qq.com/s/XTDfpec1Xe2-BZuEJ0veOg

前言

配置安全基线是网络、基础设备安全维护的基础,基线合规可以有效的防护大部分已知的攻击手段

本次介绍的整改方式均为以root权限在shell环境执行

制作脚本仅将所需命令组合成.sh即可,不做赘述

基线配置涉及多项功能的开启/关闭,切勿在已投产机器上执行,以免影响正常使用!!!

基线整改

账号口令

  • 账户密码最小长度大于8
if grep -q '^PASS_MIN_LEN' /etc/login.defs;then sed -i 's/^PASS_MIN_LEN.*/PASS_MIN_LEN   8/g' /etc/login.defs; else echo "PASS_MIN_LEN   8" >> /etc/login.defs; fi
  • 账户密码最大可用周期为90天
if grep -q '^PASS_MAX_DAYS' /etc/login.defs;then sed -i 's/^PASS_MAX_DAYS.*/PASS_MAX_DAYS   90/g' /etc/login.defs; else echo "PASS_MAX_DAYS   90" >> /etc/login.defs; fi
  • 账户密码必须包含大小写、数字、特殊字符
sed -i '/^password requisite/s/[[:space:]]*.credit=[^[:space:]]*//g' /etc/pam.d/system-auth && key=`echo {u,l,d,o}credit=-1` && sed -i 's/^password requisite.*/& '"$key"'/g' /etc/pam.d/system-auth 

# 其中ucredit为大写字母个数,lcredit为小写个数,dcredit为数字个数,ocredit为特殊字符个数
# 设置为-1代表必须包含一至多个

  • 删除与设备运行、维护等工作无关的账号
for i in {listen,gdm,webservd,nobody,nobody4,noaccess};do if grep -q "$i" /etc/passwd ;then if ! grep -q "$i":! /etc/shadow;then usermod -L $i ;fi;fi;done

认证授权

  • 文件/etc/profile中umask设置为027
if grep -iq ^umask /etc/profile; then sed -i "s/^umask.*/umask 027/g" /etc/profile; else sed -i '1i\umask 027' /etc/profile ;fi

# 即默认文件权限为750,所属用户rwx,所属组rx,其他用户无权限

  • 命令行界面超时时间设置为300S
if grep -iq '^export TMOUT' /etc/profile; then sed -i "s/^export TMOUT.*/export TMOUT=300/g" /etc/profile; else echo "export TMOUT=300" >> /etc/profile ;fi
  • 禁止root用户远程ssh登录
if grep -iq '^PermitRootLogin' /etc/ssh/sshd_config; then sed -i "s/^PermitRootLogin.*/PermitRootLogin no/g" /etc/ssh/sshd_config; else echo "PermitRootLogin no" >> /etc/ssh/sshd_config ;fi

日志审计

  • 启用syslog日志审计
if grep -iq '^authpriv.\*' /etc/*syslog.conf; then sed -i "s/^authpriv.\*.*/authpriv.* \/var\/log\/secure/g" /etc/*syslog.conf; else echo "authpriv.* /var/log/secure" >> /etc/*syslog.conf ;fi && service rsyslog restart
  • 日志文件设置为其他用户不可写入
chmod 775 /var/log/mail /var/log/boot.log /var/log/secure /var/log/messages /var/log/cron /var/log/spooler /var/log/maillog 2>/dev/null

协议安全

  • 禁止匿名VSFTP用户登录FTP
for i in `find /etc/ -name vsftpd.conf 2>/dev/null`;do if grep -iq '^anonymous_enable' $i; then sed -i "s/^anonymous_enable.*/anonymous_enable=NO/g" $i; else echo "anonymous_enable=NO" >> $i ;fi;done
  • 禁止root登录VSFTP
for i in `find /etc/ -name ftpusers 2>/dev/null`;do if ! grep -iq root $i; then echo root >> $i ;fi;done 
  • 禁用telnet
if  [ -f /etc/xinetd.d/telnet ] ;then if grep -iq ^disable /etc/xinetd.d/telnet ; then sed -i  's/^disable.*/disable = yes/g' /etc/xinetd.d/telnet; else echo "disable = yes" >> /etc/xinetd.d/telnet; fi; fi && service xinetd restart 2>/dev/null

其它安全

  • 删除隐患风险文件(.netrc、hosts.equiv、.rhosts)
for i in .netrc hosts.equiv .rhosts; do find / -maxdepth 4 -name "$i" -exec mv {} {}.bak \; 2>/dev/null ; done
  • 设置用户管理文件权限
chmod 644 /etc/group && chmod 600 /etc/shadow && chmod 644 /etc/passwd
  • 清除系统banner
mv /etc/issue /etc/issue.bak 2>/dev/null; mv /etc/issue.net /etc/issue.net.bak 2>/dev/null

========== End