zoukankan      html  css  js  c++  java
  • Linux之SSH服务端配置文件安全设置

    远程访问安全-SSH

    如何才能让ssh更加安全?

    ssh安全性和配置最佳实践:

    * 将root账户仅限制为控制台访问,不允许ssh登录

    # vim /etc/ssh/sshd_config

    PermitRootLogin no

    # systemctl restart ssh.service

    * 配置TCP Wrappers ,对远程主机进行访问控制,修改/etc/hosts.deny拒绝所有远程主机访问sshd服务,然后修改/etc/hosts.allow仅允许特定主机/网络段使用sshd服务

    # vim /etc/hosts.deny

    //sshd 为ssh服务     ALL 为所有地址

    sshd:    ALL         

    # vim /etc/hosts.allow

    //仅允许192.168.1.x网段访问

    sshd:    192.168.1.    

    * 在工作站或笔记本电脑上,关闭SSH服务并卸载ssh服务器包,工作站或笔记本没有做为服务器段来使用,所以把服务器段的ssh卸载,仅保留客户端的ssh即可。

    # systemctl stop ssh.service

    # yum -y remove openssh-server

    * 通过控制用户帐号,限制其对ssh的访问

    # vim /etc/ssh/sshd_config

    //  在该文件的最后添加以下两行

    AllowUsers    admin xiaodong    //允许的用户

    DenyUsers    xiaohong xiaofang@192.168.5.10   //禁止xiaohong登录,和禁止xiaofang使用192.168.5.10的ip地址登录

    # systemctl restart ssh.service    //重启ssh服务

    * 强制使用SSH Protocol2(版本1不安全):

    # vim /etc/ssh/sshd_config

    Protocol 2

    # systemctl restart ssh.service

    * 不支持闲置会话,并配置idle Logout Timeout 间隔:

    // 编辑以下两行

    # vim /etc/ssh/sshd_config

    ClientAliveInterval 600      // 600为秒,即600秒后无动作就自动断开连接

    ClientAliveCountMax 3

    # systemctl restart ssh.service   // 重启ssh服务

    * 禁止使用空密码登录,设置最大尝试登录次数

    // 编辑以下三行

    # vim /etc/ssh/sshd_config

    PermitEmptyPasswords no

    PasswordAuthentication yes

    MaxAuthTries 6     // 尝试次数6次

    # systemctl restart ssh.service

    * 禁用基于主机的身份验证

    # vim /etc/ssh/sshd_config

    HostbasedAuthentication no

    # systemctl restart ssh.service

    * 禁用用户的 .rhosts 文件

    # vim /etc/ssh/sshd_config

    IgnoreRhosts yes

    # systemctl restart ssh.service

    * 限制ssh,将侦听绑定到指定的可用网络接口与端口

    # vim /etc/ssh/sshd_config

    ListenAddress 172.168.8.5

    Port 56175      //可以修改ssh的端口

    * 始终保持ssh补丁版本最新(可以设置到任务计划中)

    # yum update openssh-server openssh openssh-clients -y

  • 相关阅读:
    (转)CString,int,string,char*之间的转换
    Nt函数原型
    VC 创建窗口
    设置网络延时大小
    利用寄存器进入栈值交换
    控制用户控件里面的值
    jquery animate()动画函数
    终于有点时间了
    JQuery学习笔记(三)遮罩层、阴影层
    jquery表格隔行换色
  • 原文地址:https://www.cnblogs.com/relax1949/p/8971439.html
Copyright © 2011-2022 走看看