使用SSH Root登录

新的系统安装后,默认情况下禁用Debian Linux上的root登录。当您试图以root用户身份登录到Debian Linux服务器上时,会被拒绝访问。以下是示例信息:
$ ssh root@192.168.1.172 
root@192.168.1.172's 
password: Permission denied, please try again. 
root@192.168.1.172's password:

按照如下步骤启用SSH root登录:

  1. 运行以下命令配置SSH服务器:
    echo "PermitRootLogin=yes" >> /etc/ssh/sshd_config
  2. 重启SSH服务器:

    示例命令和输出:

    # /etc/init.d/ssh restart
    [ ok ] Restarting ssh (via systemctl): ssh.service.
    

    结果:

    您可以用root用户身份使用SSH登录了。如输出以下结果,则表示登录成功:

    $ ssh root@192.168.1.172 root@192.168.1.172's password: 
    Linux starfive 5.15.0-starfive #1 SMP Wed Aug 31 08:29:37 EDT 2022 riscv64The programs included with the Debian GNU/Linux system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
    permitted by applicable law.
    Last login: Sat Sep 3 11:48:06 2022 root@starfive:~#