ubuntu,启用root登陆
在 Ubuntu 上,默认情况下,root 用户的密码是被锁定的,这意味着你不能直接以 root 身份登录。然而,你可以使用 sudo 命令来获取 root 权限。如果你确实需要启用 root 用户登录,可以按照以下步骤操作:
-
首先,你需要设置 root 用户的密码。打开终端,并输入以下命令:
sudo passwd root然后,系统将提示你输入新的 UNIX 密码并确认。
-
接下来,你应该解锁 root 用户。输入以下命令:
sudo passwd -u root -
以上就已经设置好了 root 用户的密码,现在我们需要修改 SSH daemon 的配置来允许 root 登录。编辑
/etc/ssh/sshd_config文件:sudo vim /etc/ssh/sshd_config在文件中找到
PermitRootLogin这一行,修改它如下:PermitRootLogin yes如果找不到该行,就在文件的末尾添加上述内容。
-
最后,重启 SSH daemon 以使更改生效:
sudo service ssh restart
现在,你应该能够通过 SSH 使用 root 用户登录了。
最好只是在内网环境使用
如果报错
Warning: Permanently added ‘xxx.xxx.xxx.xxx‘ (ECDSA) to the list of known hosts.
修改
sudo vim /etc/ssh/sshd_config
将StrictHostKeyChecking改为no
重启 SSH daemon 以使更改生效:
sudo service ssh restart
本文来自博客园,作者:北方Cc,转载请注明原文链接:https://www.cnblogs.com/beifangcc/p/17638205.html

浙公网安备 33010602011771号