ssh禁止root用户远程登录

最近总有友人来尝试登录我的服务器,索性就将root登录权限禁掉,su进入root用户
linux系统中root用户无所不能,为了系统安全ssh禁止root用户远程登录,必要的话使用sudo机制也是不错的选择
编辑 /etc/ssh/sshd_config
修改 PermitRootLogin将yes改为no
重启ssh服务
service sshd restart 或/etc/init.d/sshd restart

Tags: Linux

已有 3 条评论

  1. 限制 ssh 连接的 IP 地址,修改 /etc/hosts.allow 和 /etc/hosts.deny 这两个配置文件。
    vim /etc/hosts.deny #设置禁止所有ip连接服务器的ssh。
    sshd:all:deny

    vim /etc/hosts.allow #设置允许指定ip连接服务器的ssh。
    sshd:210.xx.xx.xx:allow

  2. 修改 ssh 的连接端口,建议改成非标准的高端端口【1024到65535】
    Port 11111

  3. 好人

    root账户不能使用密码只能使用密钥远程登陆

    打开sshd配置文件
    vim /etc/ssh/sshd_config 在最后面增加一行 :
    PermitRootLogin without-password
    保存配置文件后重启sshd服务
    service sshd restart

添加新评论