ubuntu22.04开启root用户登录

1、在 Ubuntu 中,通常不推荐使用 root > 用户来执行日常任务,因为这可能会导致系统安全性降低。然而,如果你确实需要这样做,你可以按照以下步骤操作:

打开终端。

  1. 设置 root 用户的密码。在终端中输入以下命令并按 Enter 键:
    sudo passwd root

然后,你需要输入你的当前用户密码以获取sudo权限,接着你将被提示输入新的 root 密码。输入你想要设置的密码,然后再次输入以确认。

  1. 启用 root 用户。输入以下命令并按 Enter 键:
    sudo passwd -u root

这将解锁 root 用户,允许其登录。

3.修改/etc/ssh/sshd_config

sudo vim /etc/ssh/sshd_config #用管理员的权限进行修改这个只读文件

permitRootLogin prohibit-password 替换成 PermitRootLogin yes

然后wq! 强制保存退出

重启服务

4.保存修改,重启ssh服务

service ssh restart

相关推荐
LSG_Dawn15 小时前
XBOX360 kinect + ROS2_humble
ubuntu·深度相机
jing.wang_202516 小时前
NVIDIA CUDA C++编程环境搭建--Windows + Ubuntu 22.04
c++·windows·ubuntu·gpu算力
黑白园19 小时前
个人台式机VMware 15及Ubuntu 16.04.5卸载以及VMware 16.2.3及Ubuntu 24.04.4安装
linux·ubuntu
想你依然心痛2 天前
从监控数据到告警管理:Prometheus与Alertmanager部署实战
ubuntu·prometheus·内网穿透·系统监控·cpolar·告警管理
黑白园2 天前
解决服务器拒绝连接导致ubuntu镜像无法下载问题 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/
ubuntu
yangpan0112 天前
ubuntu输入法安装及选择
linux·运维·ubuntu
强里秋千墙外道2 天前
Ubuntu 开机 Kernel Panic:HWE 内核升级失败 + NVIDIA DKMS 踩坑实录
linux·运维·ubuntu
啊啊啊迈 旋棍2 天前
【译】TypeScript 7 测试版已在 Visual Studio 2026 18.6 Insiders 3 中默认启用
ubuntu·typescript·visual studio
Eloudy3 天前
ubuntu 22.04安装 cuda 12.8.2
linux·运维·ubuntu
接针3 天前
Pycharm远程连接Ubuntu的conda环境
ubuntu·pycharm·conda