• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >linux shell > 一个Linux系统安全设置的Shell脚本的分享(适用CentOS)

一个Linux系统安全设置的Shell脚本的分享(适用CentOS)

作者:junjie 字体:[增加 减小] 来源:互联网

junjie 通过本文主要向大家介绍了linux shell脚本,linux shell脚本攻略,linux shell脚本实例,linux常用shell脚本,linux编写shell脚本等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

我们将常用的系统安全配置制作为一个shell脚本,只需要在服务器上运行这个shell脚本即可完成安全设置。

linux的系统安全设 置Shell脚本是第二次更新,已经大量应用在某大型媒体网站体系中,加入了之前没有想到的一些安全设置。使用方法将其复制,保存为一个shell文件, 比如security.sh.将其上传到Linux服务器上,执行sh security.sh,就可以使用该脚本了!

passwd -l xfs
passwd -l news
passwd -l nscd
passwd -l dbus
passwd -l vcsa
passwd -l games
passwd -l nobody
passwd -l avahi
passwd -l haldaemon
passwd -l gopher
passwd -l ftp
passwd -l mailnull
passwd -l pcap
passwd -l mail
passwd -l shutdown
passwd -l halt
passwd -l uucp
passwd -l operator
passwd -l sync
passwd -l adm
passwd -l lp

# chattr /etc/passwd /etc/shadow
chattr +i /etc/passwd
chattr +i /etc/shadow
chattr +i /etc/group
chattr +i /etc/gshadow

# add continue input failure 3 ,passwd unlock time 5 minite
sed -i 's#auth required pam_env.so#auth required pam_env.sonauth required pam_tally.so onerr=fail deny=3 unlock_time=300nauth required /lib/security/$ISA/pam_tally.so onerr=fail deny=3 unlock_time=300#' /etc/pam.d/system-auth
# system timeout 5 minite auto logout
echo "TMOUT=300" >>/etc/profile

# will system save history command list to 10
sed -i "s/HISTSIZE=1000/HISTSIZE=10/" /etc/profile

# enable /etc/profile go!
source /etc/profile

# add syncookie enable /etc/sysctl.conf
echo "net.ipv4.tcp_syncookies=1" >> /etc/sysctl.conf

sysctl -p # exec sysctl.conf enable
# optimizer sshd_config

sed -i "s/#MaxAuthTries 6/MaxAuthTries 6/" /etc/ssh/sshd_config
sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config

# limit chmod important commands
chmod 700 /bin/ping
chmod 700 /usr/bin/finger
chmod 700 /usr/bin/who
chmod 700 /usr/bin/w
chmod 700 /usr/bin/locate
chmod 700 /usr/bin/whereis
chmod 700 /sbin/ifconfig
chmod 700 /usr/bin/pico
chmod 700 /bin/vi
chmod 700 /usr/bin/which
chmod 700 /usr/bin/gcc
chmod 700 /usr/bin/make
chmod 700 /bin/rpm

# history security

chattr +a /root/.bash_history
chattr +i /root/.bash_history

# write important command md5
cat > list << "EOF" && /bin/ping /bin/finger /usr/bin/who /usr/bin/w /usr/bin/locate /usr/bin/whereis /sbin/ifconfig /bin/pico /bin/vi /usr/bin/vim /usr/bin/which /usr/bin/gcc /usr/bin/make /bin/rpm EOF for i in `cat list` do if [ ! -x $i ];then echo "$i not found,no md5sum!" else md5sum $i >> /var/log/`hostname`.log
fi
done
rm -f list</div>

</div>

您可能想查找下面的文章:

  • 使用Linux shell脚本实现FTP定时执行批量下载指定文件
  • Linux shell脚本输出日志笔记整理(必看篇)
  • shell脚本 自动创建用户详解及实例代码
  • Linux Shell中三种引号的用法及区别
  • linux脚本判断条件总结(必看)
  • linux shell发送Email邮件的方法详解
  • Linux shell 之 提取文件名和目录名的一些方法总结
  • shell脚本实现输入密码显示星号
  • linux shell在while中用read从键盘输入的实现
  • shell脚本通过expect实现自动单边无密登录功能

相关文章

  • 什么是Shell?Shell脚本基础知识详细介绍
  • 一键备份gitolite服务器的Shell脚本
  • linux命令详解之useradd命令使用方法
  • linux patch 命令小结(收藏)
  • Shell正则表达式之grep、sed、awk实操笔记
  • Shell脚本避免重复执行的方法
  • linux rsync同步命令(值得收藏)
  • 浅析Linux系统下安装wetty和使用说明
  • Shell脚本调快调慢系统时间(测试服务器时使用)
  • Shell脚本统计文件行数的8种方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Shell中比较大小简洁总结
    • shell脚本联合PHP脚本采集网站的pv和alexa排名
    • linux 使用NSF 映射远程磁盘目录的实现
    • shell脚本正则匹配文件中的Email并写入到文件中代码分享
    • Linux Shell脚本系列教程(四):使用函数添加环境变量
    • Shell 命令执行顺序分析[图]
    • linux Shell入门:掌握Linux,OS X,Unix的Shell环境
    • linux系统安装字体详细介绍
    • 两个备份数据库的shell脚本
    • linux shell 字符串操作(长度,查找,替换)详解

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有