美文网首页
Linux系统 SSH 服务安全配置简要说明

Linux系统 SSH 服务安全配置简要说明

作者: 凉风儿 | 来源:发表于2017-04-06 13:04 被阅读0次

    说明

    直接使用root帐号虽然方便,但是危险,犯下的错误也是致命的,通常使用普通帐号登录然后再切换到root帐号,或使用sudo,另外禁止任意地址通过ssh连接到服务器。

    步骤

    1. 将 ssh 连接端口改成非标准的高端端口【1024到65535】,禁止 root 帐号直接登录,配置文件位置 /etc/ssh/sshd_config;

    Port 22022 # 端口
    PermitRootLogin no # 禁止 root 直接登录

    1. 重启 sshd 服务;
    /etc/init.d/sshd restart # 重启 sshd 服务
    
    1. 限制 ssh 连接的 IP 地址,只允许用户指定的 IP 地址可以 ssh 连接服务器。
      修改 /etc/hosts.allow 和 /etc/hosts.deny 这两个配置文件。
    > vim /etc/hosts.deny #设置禁止所有ip连接服务器的sshd
    

    文件末尾追加:sshd:all:deny

    > vim  /etc/hosts.allow    #设置允许指定ip连接服务器的sshd
    

    文件末尾追加:sshd:210.xx.xx.xx:allow

    1. 用普通账号登录ssh后,用su命令切换到root账号即可。
    > su - root
    

    参考

    https://help.aliyun.com/knowledge_detail/41212.html?spm=5176.doc51403.2.7.O6ePFi

    相关文章

      网友评论

          本文标题:Linux系统 SSH 服务安全配置简要说明

          本文链接:https://www.haomeiwen.com/subject/uoigottx.html