1. 编辑 /etc/ssh/sshd_config 文件

    #修改 PermitRootLogin 为true
    $ sudo vim /etc/ssh/sshd_config
    #LoginGraceTime 2m
    #PermitRootLogin prohibit-password
    #允许root用户登录
    PermitRootLogin yes
    #StrictModes yes
    #MaxAuthTries 6
    #MaxSessions 10
    
    #允许使用密码登录
    #PasswordAuthentication no
    PasswordAuthentication yes
    
  2. 重置root密码

    sudo passwd root
    
  3. 重启ssh服务

    sudo  systemctl  restart  sshd