zoukankan      html  css  js  c++  java
  • Linux安全加固

    Centos 7 安全加固(最小化系统安装)

    1、锁定无用的账户

    sh-4.2# awk -F: '{print $1}' /etc/passwd | grep -E -v "root|ftp*" | xargs -n 1 passwd -l

    2、创建普通用户(以普通用户执行系统操作)

    sh-4.2# useradd -u 917 User
    sh-4.2# groupmod -g 917 User

    3、关闭ssh dns反向解析

    sh-4.2# sed -i 's:#UseDNS no:UseDNS no:' /etc/ssh/sshd_config
    sh-4.2# systemctl reload sshd.service

    4、设置密码最大有效周期

    sh-4.2# chage -d 0 User          # 初次登录必须更改密码
    sh-4.2# chage -M 90 -m 7 -W 7 User  #用户90天后密码过期,至少7天后才能修改密码,密码过期前7天开始收到告警信息
    sh-4.2# vi /etc/login.defs
    PASS_MAX_DAYS   90
    PASS_MIN_LEN    8

    5、关闭root登录权限

     

    6、设置自动退出时间

    sh-4.2# echo "TMOUT=1800" >> /etc/profile
    sh-4.2# source /etc/profile

    7、关闭linux部分快捷键

    sh-4.2# sed -i '1,$ s/^/#/' /usr/lib/systemd/system/ctrl-alt-del.target
    sh-4.2# init q

    9、修改文件系统最大打开数

    sh-4.2# sed -i '$a * soft nofile 65535' /etc/security/limits.conf
    sh-4.2# sed -i '$a * hard nofile 65535' /etc/security/limits.conf
    sh-4.2# ulimit -n 65535    # 临时设置

    10、关闭IPV6

    sh-4.2# sed -i '$a net.ipv6.conf.all.disable_ipv6 = 1' /etc/sysctl.conf 
    sh-4.2# sed -i '$a net.ipv6.conf.default.disable_ipv6 = 1' /etc/sysctl.conf
    sh-4.2# sysctl -p

    此内容参考:https://linux.cn/article-4935-1.html

    11、特殊文件权限控制

    sh-4.2# chmod 700 /usr/bin/ping
    sh-4.2# chmod 700 /usr/bin/who
    sh-4.2# chmod 700 /usr/bin/w 
    sh-4.2# chmod 700 /usr/bin/whereis
    sh-4.2# chmod 700 /usr/sbin/ifconfig
    sh-4.2# chmod 700 /usr/bin/gcc
    sh-4.2# chmod 700 /usr/bin/make
    sh-4.2# chmod 700 /usr/bin/rpm
    sh-4.2# chattr +i /etc/passwd 
    sh-4.2# chattr +i /etc/shadow 
    sh-4.2# chattr +i /etc/group 
    sh-4.2# chattr +i /etc/gshadow 
    sh-4.2# chattr +a /root/.bash_history 
    sh-4.2# chattr +i /root/.bash_history

    12、开启防火墙

    sh-4.2# rpm -qa | grep "firewall" | xargs rpm -e --nodeps
    sh-4.2# yum list iptables*
    sh-4.2# systemctl start iptables
    sh-4.2# iptables -F
    sh-4.2# iptables -A INPUT -p tcp --dport 22 -j ACCEPT
    sh-4.2# iptables -A INPUT -j DROP
    sh-4.2# service iptables save
    # 这里只是简单的列出基本的iptables规则,主要还是根据自己的业务场景进行设定

    14、系统在线升级

    15、升级openssh

  • 相关阅读:
    jQuery EasyUI API 中文文档 数字框(NumberBox)
    jQuery EasyUI API 中文文档 数值微调器(NumberSpinner)
    jQuery EasyUI API 中文文档 日期时间框(DateTimeBox)
    jQuery EasyUI API 中文文档 微调器(Spinner)
    jQuery EasyUI API 中文文档 树表格(TreeGrid)
    jQuery EasyUI API 中文文档 树(Tree)
    jQuery EasyUI API 中文文档 属性表格(PropertyGrid)
    EntityFramework 数据操作
    jQuery EasyUI API 中文文档 对话框(Dialog)
    jQuery EasyUI API 中文文档 组合表格(ComboGrid)
  • 原文地址:https://www.cnblogs.com/guge-94/p/10451888.html
Copyright © 2011-2022 走看看