• SSH安全配置


         配置基于CentOS7

    配置文件: 

      /etc/ssh/sshd_config

    设定文件权限

    chown root:root /etc/ssh/sshd_config
    chmod og-rwx /etc/ssh/sshd_config

    配置文件

    ####   这里设置了禁止root登录,请确保一定提前建立好登录用户

    # 设定日志级别
    LogLevel INFO
    # 用户登录失败,在切断连接前服务器需要等待的时间,单位为秒
    LoginGraceTime 60
    # 不允许root登录
    PermitRootLogin no
    # 密码验证失败允许次数
    MaxAuthTries 4
    # 这是通过在RSA认证成功后再检查 ~/.rhosts 或 /etc/hosts.equiv 进行认证的。出于安全考虑,建议使用默认值"no"。
    HostbasedAuthentication no
    # 是否在 RhostsRSAAuthentication 或 HostbasedAuthentication 过程中忽略 .rhosts 和 .shosts 文件。
    不过 /etc/hosts.equiv 和 /etc/shosts.equiv 仍将被使用。推荐设为默认值"yes"。
    IgnoreRhosts yes
    # 不允许空密码登录
    PermitEmptyPasswords no
    # 禁止下x11转发
    X11Forwarding no
    # 指定是否允许 sshd(8) 处理 ~/.ssh/environment 以及 ~/.ssh/authorized_keys 中的 environment= 选项。
    默认值是"no"。如果设为"yes"可能会导致用户有机会使用某些机制(比如LD_PRELOAD)绕过访问控制,造成安全漏洞
    PermitUserEnvironment no
    # ssh会话存活时间
    ClientAliveInterval 300
    # 到达会话存活时间,发送alive给服务器的次数
    ClientAliveCountMax 0
    # 使用ssh协议2
    Protocol 2
    # 只使用经批准的MAC算法
    MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
    # 允许的用户通过ssh登录
    AllowUsers  redhat
    # 允许的组通过ssh登录
    AllowGroups root redhat
    # 用户登陆前的提示信息文件路径
    Banner /etc/issue.net
  • 相关阅读:
    李航统计学习方法(第二版)(六):k 近邻算法实现(kd树(kd tree)方法)
    ActiveMQ的安装和启动
    HTML select autofocus 属性
    macpath (File & Directory Access) – Python 中文开发手册
    Java Bitset类
    Linux zip命令
    HTML DOM Keygen 对象
    tanh (Numerics) – C 中文开发手册
    no-shadow (Rules) – Eslint 中文开发手册
    require-await (Rules) – Eslint 中文开发手册
  • 原文地址:https://www.cnblogs.com/zydev/p/13094465.html
Copyright © 2020-2023  润新知