惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
P
Privacy International News Feed
T
Tenable Blog
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
S
Securelist
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Cyberwarzone
Cyberwarzone
月光博客
月光博客
T
The Blog of Author Tim Ferriss
Scott Helme
Scott Helme
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
C
Cisco Blogs
aimingoo的专栏
aimingoo的专栏
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
阮一峰的网络日志
阮一峰的网络日志
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
Security Latest
Security Latest
Blog — PlanetScale
Blog — PlanetScale
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
博客园 - 三生石上(FineUI控件)
I
InfoQ
Spread Privacy
Spread Privacy
B
Blog RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
MongoDB | Blog
MongoDB | Blog
C
CERT Recently Published Vulnerability Notes
A
About on SuperTechFans
博客园_首页
Engineering at Meta
Engineering at Meta
Project Zero
Project Zero
Latest news
Latest news

博客园 - emanlee

ubuntu 设置北京日期时间 mysql 在新电脑上导入,出现错误:ERROR at line 4019: Unknown command '\''. - emanlee 安装 yarn npm : 无法加载文件 C:\Program Files\nodejs\npm.ps1,因为在此系统上禁止运行脚本。 - emanlee VS code, 最近打开过哪些项目或文件夹,把这些备份下来,到另外一台电脑上恢复 傲梅分区助手 【好用】 ubuntu 可以使用Windows远程桌面连接吗?【可以】 把xshell的全部连接和密码,从一台Windows 10电脑,迁移到Windows11电脑。 Windows 远程桌面(mstsc)完整迁移方案(含历史连接记录、RDP 配置、保存的账号密码)【可行】 Endnote,如何能完整迁移库和模版 ubuntu 安装 locate “华为杯”第八届中国研究生人工智能创新大赛 当数据量很大时,执行 mysql> source filename.sql 很慢,有什么办法更快 pip install django-ranged-response==0.2.0 部署Vue+Django 04c,mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory Ubuntu Server 24.04 安装 MySQL, ./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory ubuntu server 24.04: 如何设置默认采用 Xorg 方式登录 Ubuntu Server 24.04 设置锁屏时间 Ubuntu Server 启动过程中,比较慢 Job systemd-networkd-wait-online.service/start running Ubuntu snap install 安装todesk是否必须检查 CPU 是否支持 AVX / AVX2 命令 Ubuntu Server 24.04下解决SunloginClient 向日葵依赖libgconf-2-4安装问题 Ubuntu Server 24.04 安装图形界面 ubuntu server 24.04 安装 中文输入法 Ubuntu Server 24.04 安装浏览器firefox Ubuntu Server 24.04 安装todesk【先联网,CPU必须支持 AVX / AVX2 】 Ubuntu Server 24.04 安装中文,汉字 Python赋值,什么时候传引用? 大驼峰命名法 python 容易理解类和对象的例子 django+mysql: 如何添加一个新的超级用户? Python 异常体系核心:BaseException 及其四大子类 Python 匿名函数(lambda)举例 Python函数内部的局部变量和全局变量 订书钉规格 在Navicat中复制带有自动增长id字段的表格,如何把新表格的自动增长id重新设置为从1开始 科研02 期刊和会议的质量等级 Vue 2,父组件中点击一个按钮,更新子组件(重新加载子组件) 汉明距离(Hamming distance) Modbus slave模拟的从站 如何主动发送数据给主站 Word中,表格中的文字在一行的偏下方,没有垂直居中 在线把汉字转拼音字母 Navicat中复制并修改MySQL表,保存时,出现未知的列的错误 WinSCP 便携版、绿色版 下载 centos / Linux 上,非管理员用户安装 miniconda FTP 服务器设置(FileZilla Server) Windows主机上的Device/Credential Guard功能与VMware Workstation虚拟化冲突导致 Navicat 备份连接
Ubuntu Server 24.04 启用root用户
emanlee · 2026-05-04 · via 博客园 - emanlee

Ubuntu Server 24.04 启用root用户

Ubuntu Server 24.04 启用 root 登录 完整草稿(可直接照着执行)

一、设置 root 密码(启用 root 账号)

Ubuntu 默认 root 未设置密码,无法登录,先设密码:

按提示输入当前普通用户密码,然后设置 root 新密码、确认密码。

二、允许 SSH 远程登录 root(关键)

编辑 SSH 配置文件:

sudo nano /etc/ssh/sshd_config

找到这一行:

#PermitRootLogin prohibit-password 

三、保存退出

nano 编辑器:

Ctrl+O → 回车保存 → Ctrl+X 退出

四、重启 SSH 服务生效

sudo systemctl restart ssh

五、测试登录

输入刚设置的 root 密码即可登录。

六、补充:关闭 root 登录(以后想禁用)

sudo nano /etc/ssh/sshd_config 

改回:

PermitRootLogin prohibit-password 

重启 SSH:

sudo systemctl restart ssh 

安全提醒

生产环境不建议开启 root SSH 直接登录,日常用普通用户 + sudo 即可;仅内网测试、本地虚拟机可以开启。

 =========================

Ubuntu Server 24.04,ssh 可以用root登录了。但是, desktop桌面无法使用root登录。

 Ubuntu 默认 SSH 允许 root ≠ 图形界面允许 root。桌面被禁是因为 GDM 配置 + PAM 认证两道锁,需要手动放开。下面直接给可复制的完整步骤(适用于 Ubuntu Server 24.04 + GNOME 桌面)。

可行,可用


一、先确认 root 密码已设置

sudo passwd root
# 输入两次 root 密码(你 SSH 登录用的那个) 

二、修改 GDM 配置,允许 root 登录 

sudo nano /etc/gdm3/custom.conf 

找到 [security] 段,添加 / 取消注释: 

[security]
AllowRoot=true 

图片

保存退出:Ctrl+O → 回车 → Ctrl+X


三、注释 PAM 里禁止 root 的规则(关键)

1)gdm-password

sudo nano /etc/pam.d/gdm-password

找到这一行,在行首加 # 注释掉

auth required pam_succeed_if.so user != root quiet_success
 

图片

 保存退出:Ctrl+O → 回车 → Ctrl+X

2)gdm-autologin(也要改)

sudo nano /etc/pam.d/gdm-autologin

同样注释掉(前面加 # ):

auth required pam_succeed_if.so user != root quiet_success

图片

  保存退出:Ctrl+O → 回车 → Ctrl+X


编辑 GDM 的默认配置: 

sudo nano /etc/gdm3/greeter.dconf-defaults 

找到这段(没有就直接加在文件末尾):

[org/gnome/login-screen]
#disable-user-list=true 

改成(去掉注释、设为 false):

[org/gnome/login-screen]
disable-user-list=false 

保存退出(Ctrl+O 回车,Ctrl+X)。

然后重启 gdm:【会断开todesk】

sudo systemctl restart gdm3

四、重启 GDM 生效 

sudo systemctl restart gdm3
# 或直接重启系统
sudo reboot 

五、登录测试

重启后在登录界面:

  • 用户名填:root
  • 密码填:你设置的 root 密码
  • 能进桌面即成功。

新问题:以前在另外一个用户下配置好的中文输入法,在root下不能使用了。


常见坑

  1. Wayland 下仍失败:登录界面点齿轮 → 选 GNOME on Xorg 再登录。
  2. 改完没重启 GDM:PAM/GDM 配置不重启不生效。
  3. 只改了一个 PAM 文件gdm-passwordgdm-autologin 两个都要注释