ubuntu桌面版开启root用户自动登陆
ubuntu22.04桌面版默认不支持root用户登陆,测试环境每次都要敲个sudo,实在麻烦
- 先给root用户设置密码
1
sudo passwd root
- 将下面两个文件
/etc/pam.d/gdm-password
和/etc/pam.d/gdm-autologin
中的一行代码1
auth required pam_succeed_if.so user != root quiet_success
- 修改
/root/.profile
文件1
2- mesg n 2> /dev/null || true
+ tty -s && mesg n || true - 修改
/etc/gdm3/custom.conf
,没有这个文件就在设置里开启自动登录,或者自己创建1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30# GDM configuration storage
#
# See /usr/share/gdm/gdm.schemas for a list of available options.
[daemon]
AutomaticLoginEnable=true
- AutomaticLogin=pblood
+ AutomaticLogin=root
# Uncomment the line below to force the login screen to use Xorg
#WaylandEnable=false
# Enabling automatic login
# Enabling timed login
# TimedLoginEnable = true
# TimedLogin = user1
# TimedLoginDelay = 10
[security]
[xdmcp]
[chooser]
[debug]
# Uncomment the line below to turn on debugging
# More verbose logs
# Additionally lets the X server dump core if it crashes
#Enable=true
另外,桌面版也不支持root用户远程登陆,下面是开启方法
- 安装openssl-server
1
apt install openssh-server
- 修改
/etc/ssh/sshd_config
文件1
2- #PermitRootLogin prohibit-password
+ PermitRootLogin yes - 重启ssh服务测试:
1
service ssh restart
1
ssh root@localhost
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Pbloodの小岛!
评论