通过以太网使用SSH Root账户登录

重新安装系统后,默认禁用Debian Linux上的root进行登录。当您试图以root的身份登录到Debian Linux服务器时,您的访问将被拒绝。以下是示例信息:
$ ssh root@192.168.120.41
ssh: connect to host 192.168.120.41 port 22: Connection refused
若要启用SSH root身份登录,请执行以下步骤:
  1. 运行以下命令配置SSH服务器:
    echo 'PermitRootLogin=yes'  | sudo tee -a /etc/ssh/sshd_config
  2. 重启SSH服务器:
    sudo systemctl restart sshd
    结果:

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

    示例输出

    $ ssh root@192.168.120.41
    root@192.168.120.41's password:  
    Linux starfive 5.15.0-starfive #1 SMP Fri Feb 24 03:26:44 EST 2023 riscv64
    
    The 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: Mon Feb 27 08:05:28 2023 from 192.168.120.130
    root@starfive:~#
  3. 使用root账户进行登录,请参见通过以太网使用SSH登录