Ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码

时间:2024-01-15 16:31:26

user@ubuntu12:~$ sudo password root //用sudo修改账户

1、根据提示输入当前用户的密码;

2、修改成功之后你就可以使用root账号了,可以使用su root 命令切换到root;

3、但是修改之后,直接用root账号无法登录远程终端,这时还需要修改ssh配置文件;

4、/etc/ssh/sshd_config修改配置文件;

5、vim /etc/ssh/ssh_vonfig 编辑文件

# Authentication :
 LoginGraceTime 120
 PermitRootLogin without-password (该处也可能是prohibit-password,不管是什么,修改成yes就可以了 )
 StrictModes yes

6、将PermitRootLoginwithout-passwo 修改为PermitRootLoginyes,如下:
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

7、这时,一定要重启一Fssh服务
(本人就是没有重启,找了半天才发现)
user@ubuntu;~$ sudo service ssh restart

8、重置root密码,启动系统,显示GRUB选择菜单(如果默认系统启动过程不显示GRUB菜单,则在系统启动时需要长按[Shift]键,显示GRUB界面),选择Advanced options for Ubuntu,按下[Enter]进入,选择recovery mode,不要按下回车键。

Ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码

Ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码

Ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码

9、按下[e]键进入命令编辑状态,到 linux /boot/vmlinuz-....... ro recovery nomodeset 所在行,将“ro recovery nomodeset”替换为“quiet splash rw init=/bin/bash”,按下[F10]或者[Ctrl+x]重启系统。

Ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码

Ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码

Ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码

10、此时以root身份启动一个可读写的bash,直接使用命令passwd更改root密码,然后按下[Ctrl+Alt+Delete]重启系统。

Ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码

Ubuntu 服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码

11、系统启动后进入字符终端[Ctrl+Alt+F<1...6>],使用root账户和密码登录系统,然后进行恢复管理账户状态操作。(图形界面终端为[Ctrl+Alt+F<7>])