如何检查 ubuntu 服务器上是否禁用了 root 登录

how to check if root login is disabled on ubuntu server

我尝试使用 ssh 密钥对以 root 用户身份登录 lightsail 实例机器。

我收到的回复是

Please login as the user "ubuntu" rather than user "root".

我想知道如何检查使用 root 登录是否被禁用,如果被禁用,如何使用 ssh 密钥启用它。

在 Ubuntu,对于 SSH,这是通过 SSH 服务器配置进行配置的: /etc/ssh/sshd_config

在那里你应该有一行:

PermitRootLogin yes

这就是您要找的。