1. #!/bin/sh
  2. # desc: setup linux system security
  3. # powered by www.lvtao.net
  4. #account setup
  5.  
  6. passwd -l xfs
  7. passwd -l news
  8. passwd -l nscd
  9. passwd -l dbus
  10. passwd -l vcsa
  11. passwd -l games
  12. passwd -l nobody
  13. passwd -l avahi
  14. passwd -l haldaemon
  15. passwd -l gopher
  16. passwd -l ftp
  17. passwd -l mailnull
  18. passwd -l pcap
  19. passwd -l mail
  20. passwd -l shutdown
  21. passwd -l halt
  22. passwd -l uucp
  23. passwd -l operator
  24. passwd -l sync
  25. passwd -l adm
  26. passwd -l lp
  27.  
  28. # chattr /etc/passwd /etc/shadow
  29. chattr +i /etc/passwd
  30. chattr +i /etc/shadow
  31. chattr +i /etc/group
  32. chattr +i /etc/gshadow
  33.  
  34. # add continue input failure ,passwd unlock time minite
  35. 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
  36. # system timeout minite auto logout
  37. echo "TMOUT=300" >>/etc/profile
  38.  
  39. # will system save history command list to
  40. sed -i "s/HISTSIZE=1000/HISTSIZE=10/" /etc/profile
  41.  
  42. # enable /etc/profile go!
  43. source /etc/profile
  44.  
  45. # add syncookie enable /etc/sysctl.conf
  46. echo "net.ipv4.tcp_syncookies=1" >> /etc/sysctl.conf
  47.  
  48. sysctl -p # exec sysctl.conf enable
  49. # optimizer sshd_config
  50.  
  51. sed -i "s/#MaxAuthTries 6/MaxAuthTries 6/" /etc/ssh/sshd_config
  52. sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
  53.  
  54. # limit chmod important commands
  55. chmod /bin/ping
  56. chmod /usr/bin/finger
  57. chmod /usr/bin/who
  58. chmod /usr/bin/w
  59. chmod /usr/bin/locate
  60. chmod /usr/bin/whereis
  61. chmod /sbin/ifconfig
  62. chmod /usr/bin/pico
  63. chmod /bin/vi
  64. chmod /usr/bin/which
  65. chmod /usr/bin/gcc
  66. chmod /usr/bin/make
  67. chmod /bin/rpm
  68.  
  69. # history security
  70.  
  71. chattr +a /root/.bash_history
  72. chattr +i /root/.bash_history
  73.  
  74. # write important command md5
  75. 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
  76. fi
  77. done
  78. 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. 【[AHOI2012]树屋阶梯】

    卡特兰数! 至于为什么是卡特兰数,就稍微说那么一两句吧 对于一个高度为\(i\)的阶梯,我们可以在左上角填一个高度为\(k\)的阶梯,右下角填一个高度为\(i-1-k\)的阶梯剩下的我们用一个大的长方 ...

  2. luogu P1768 天路

    嘟嘟嘟 01分数规划之最优比率环. 主要是发一下基于dfs的spfa.跑的贼快,原来总用时2000多ms还TLE了两个点,改成dfs后总用时直降43ms! #include<cstdio> ...

  3. PAT (Basic Level) Practise (中文)-1040. 有几个PAT(25)

    1040. 有几个PAT(25)     http://www.patest.cn/contests/pat-b-practise/1040 字符串APPAPT中包含了两个单词“PAT”,其中第一个P ...

  4. 消息中间件JMS(二)

    之前介绍了ActiveMQ下载与安装,并且启动了.下面进行ActiveMQ的Demo 1. JMS入门Demo 1.1 点对点模式 点对点模式主要建立在一个队列上面,当连接一个队列的时候,发送端不需要 ...

  5. spring(一)-基本概念

    1.定义与特点 定义:一个分模块的一站式后台开发框架. 特征: (1)比起EJB,更轻量级别的容器框架,模块形式组织,只需要调用相应模块(jdbc.springmvc) (2)Spring IOC低耦 ...

  6. JNI 和 socket api

    1.JavaVM 和 JNIEnvJNIEnv是一个与线程相关的变量,不同线程的JNIEnv彼此独立.JavaVM是虚拟机在JNI层的代表,在一个虚拟机进程中只有一个JavaVM,因此该进程的所有线程 ...

  7. IP检验字段为啥只检验地址部分

    在首部中的错误比在数据中的错误更重 如:一个错误的地址可能导致分组被投递到错误的主机.许多主机并不检查投递给它们的分组是否 确定是要投递给它们,它们假定网络从来不会把别人的分组包传递给自己.数据不参加 ...

  8. java连接Redis初始化jedis失败!

    Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstant ...

  9. 【原创】关于skip-gram的个人理解

    ★skip-gram的关键术语与详细解释:   [语料]—— 所有句子文档(当然会出现大量重复的单词) [词典(可用V维的onehot编码来表示)]—— 语料中出现的所有单词的集合(去除了重复词) [ ...

  10. Hello,移动WEB—px,dp,dpr像素基础

    问题点1:iphone5分辨率:640 * 1136 dp,为什么chrome浏览器F12中显示的320 *568??         iPhone5 分辨率640 * 1136指的是物理像素,而实际 ...