zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    【CodeForces】[366A]Dima and Guards
    Linux将程序前台转后台执行
    Storm在Mesos上跑与不在的运行命令区别
    去掉SSH KEY密码
    git 退回到倒数第二次提交
    浅析UGC、PGC和OGC
    linux主机名与IP地址配置文件
    wget ERROR 404: Not Found.
    cpuacct (CPU Accounting Controller)
    Ansible的安装与使用
  • 原文地址:https://www.cnblogs.com/zydev/p/13094465.html
Copyright © 2011-2022 走看看