#!/bin/sh
# desc: setup linux system security
# powered by www.lvtao.net
#account setup 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 ,passwd unlock time 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 minite auto logout
echo "TMOUT=300" >>/etc/profile # will system save history command list to
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 /bin/ping
chmod /usr/bin/finger
chmod /usr/bin/who
chmod /usr/bin/w
chmod /usr/bin/locate
chmod /usr/bin/whereis
chmod /sbin/ifconfig
chmod /usr/bin/pico
chmod /bin/vi
chmod /usr/bin/which
chmod /usr/bin/gcc
chmod /usr/bin/make
chmod /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

执行sh security.sh

Linux的系统安全设置Shell脚本的更多相关文章

  1. 【linux】系统初始化的shell脚本

    根据参考网上的一些文章,总结出来一个系统初始化的shell脚本 1.初始化脚本 #!/bin/bash cat << EOF +------------------------------ ...

  2. linux服务器系统负载监控-shell脚本

    一.监控服务器系统负载情况: 1.用uptime命令查看当前负载情况(1分钟,5分钟,15分钟平均负载情况) # uptime   15:43:59 up 186 days, 20:04,  1 us ...

  3. Linux学习Day6:编写Shell脚本

    Shell脚本命令的工作方式有两种: 交互式(Interactive):用户每输入一条命令就立即执行. 批处理(Batch):由用户事先编写好一个完整的Shell脚本,Shell会一次性执行脚本中诸多 ...

  4. java classpath批量设置shell脚本

    java classpath批量设置shell脚本   注意:linux bash jar文件之间的分隔符是':'    export JAR_HOME=path to directory which ...

  5. linux c程序中获取shell脚本输出的实现方法

    linux c程序中获取shell脚本输出的实现方法 1. 前言Unix界有一句名言:“一行shell脚本胜过万行C程序”,虽然这句话有些夸张,但不可否认的是,借助脚本确实能够极大的简化一些编程工作. ...

  6. Linux自动安装JDK的shell脚本

    Linux自动安装JDK的shell脚本 A:本脚本运行的机器,Linux B:待安装JDK的机器, Linux 首先在脚本运行的机器A上确定可以ssh无密码登录到待安装jdk的机器B上,然后就可以在 ...

  7. linux系统配置文件或shell脚本批量注释

    1. 配置文件批量注释 1.1 批量注释 ① 进入命令行模式,按ctrl + v进入 visual block模式,键盘上下箭头选中多行,把需要注释的行标记起来 ② 按大写字母I,再输入注释符:# ③ ...

  8. linux 的基本操作(编写shell 脚本)

    终于到shell 脚本这章了,在以前笔者卖了好多关子说shell脚本怎么怎么重要,确实shell脚本在linux系统管理员的运维工作中非常非常重要.下面笔者就带你正式进入shell脚本的世界吧. 到现 ...

  9. Linux入门第五天——shell脚本入门(上)基本概念

    一.什么是shell脚本 Shell 脚本(shell script),是一种为 shell 编写的脚本程序. 二.shell入门 1.先导知识 变量知识补充:https://www.cnblogs. ...

随机推荐

  1. Ubuntu 12.04 安装Chrome步骤

    一.添加PPA 从Google Linux Repository(http://www.google.com/linuxrepositories/)下载安装Key,或把下面的代码复制进终端,回车,需要 ...

  2. 每天一个linux命令(21):chgrp,chown,chmod

    这三个命令都是改变文件属性与权限的,就放一起写了 charp:改变文件所属用户组 chown:改变文件所属者 chmod:改变文件的权限 一个文件对于owner,group ,others有不同的权限 ...

  3. HDU 5025 Saving Tang Monk 【状态压缩BFS】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5025 Saving Tang Monk Time Limit: 2000/1000 MS (Java/O ...

  4. [19/03/17-星期日] 常用类_Calendar日历类&GregorianCalendar公历日历类

    一.概念 Calendar 类是一个抽象类,为我们提供了关于日期计算的相关功能,比如:年.月.日.时.分.秒的展示和计算. GregorianCalendar 是 Calendar 的一个具体子类,提 ...

  5. jdbc连接各种数据库字符串

    oracle driverClass:oracle.jdbc.driver.OracleDriver url:jdbc:oracle:thin:@127.0.0.1:1521:dbname mysql ...

  6. Vue nodejs商城项目- 前后端数据传递

    .利用Mongoose查询MongoDB 通过mongoose插件可以简捷地从mondodb中获取数据,首先安装mongoose: cnpm install mongoose --save   使用m ...

  7. Android 初步-Android文件目录介绍

    src:存放的是应用程序使用到的java文件. gen:系统自动生成的目录,不需要程序员进行修改,包含了R.java文件.该文件包含了 程序使用到的资源文件对应的唯一资源ID,注意:如果R文件生成错误 ...

  8. Python基础—15-正则表达式

    正则表达式 应用场景 特定规律字符串的查找替换切割等 邮箱格式.URL.IP等的校验 爬虫项目中,特定内容的提取 使用原则 只要是能够使用字符串函数解决的问题,就不要使用正则 正则的效率较低,还会降低 ...

  9. mysql快速导入导出数据

    --导入 select * from inhos_genoperation(表名) where UPLOAD_ORG_CODE='***' into outfile '/tmp/inhos_genop ...

  10. eclipse 突然debug模式不能正常运行了

    eclipse 突然debug模式不能正常运行了,但非debug模式却能正常运行.debug模式不能正常启动的现象描述如下:    点击eclipse debug按钮,console窗口显示tomca ...