【Linux】Ubuntu设置自动登录图形界面和远程shell

1. root 自动登录图形界面

ubuntu 默认是禁止管理员登录图形界面的,想要以 root 身份登录,需要经过以下配置:

cd /usr/share/lightdm/lightdm.conf.d && chmod 644 50-ubuntu.conf && vim 50-ubuntu.conf

在文件末尾添加两行代码:

greeter-show-manual-login=true
all-guest=false

然后修改另一个文件:

cd /root && vim .profile

每个系统可能不一样,在我的环境下,最后一行是:

mesg n 2> /dev/null || true

在行首加上语句 tty -s && ,结果该行代码被改为:

tty -s && mesg n 2> /dev/null || true

2. root 免密登录图形界面

cd /etc/pam.d && chmod 644 gdm-autologin && vim gdm-autologin
# 注释掉auth required pam_success_if.so user!=root quiet_success这一行
cd /etc/pam.d && chmod 644 gdm-password && vim gdm-password
# 注释掉auth required pam_success_if.so user!=root quiet_success这一行
cd /etc/gdm3 && chmod 644 custom.conf && vim custom.conf
# 修改下列配置项:
# AutomaticLoginEnable = true
# AutomaticLogin = root
# TimedLoginEnable = true
# TimedLogin = root
# AutomaticLoginEnable=True
# AutomaticLogin=root

3. 允许 root 用户登录远程 shell:

sudo passwd root
=== 输入密码
sudo vim /etc/ssh/sshd_config 
=== 找到 #Authentication,将 PermitRootLogin 参数修改为 yes
=== 找到 #Authentication,将 PasswordAuthentication 参数修改为 yes
=== 保存并退出
sudo service ssh restart

猜你喜欢

转载自blog.csdn.net/Elford/article/details/126100024