ubuntu启用root账号并登陆

bash 复制代码
sudo passwd root
 # 密码输入8位

然后通过

bash 复制代码
ssh root@192.168.1.12

如果报

bash 复制代码
cn@cn-VMware-Virtual-Platform:~$ ssh root@192.168.1.12
root@192.168.1.12's password: 
Permission denied, please try again.
root@192.168.1.12's password:

检查 SSH 是否允许 root 登录

执行:

bash 复制代码
sudo grep PermitRootLogin /etc/ssh/sshd_config

如果输出 PermitRootLogin yes 或 PermitRootLogin without-password,则允许(或允许密钥登录)。

如果输出 PermitRootLogin no 或 prohibit-password,则禁止密码登录。

如果该行被注释(#PermitRootLogin ...),则默认值为 prohibit-password,禁止密码登录。

修改方法(如果需要):

bash 复制代码
sudo nano /etc/ssh/sshd_config

找到 #PermitRootLogin prohibit-password 或类似行,改为:

txt 复制代码
PermitRootLogin yes

保存文件 :按 Ctrl+O 回车保存,然后 Ctrl+X 退出 nano。

保存后重启 SSH:

bash 复制代码
sudo systemctl restart ssh

再次尝试用 root 登录:

bash 复制代码
ssh root@你的IP地址

输入你刚刚设置的 root 密码,应该就能成功了。

相关推荐
风吹夏回13 小时前
TypeScript 快速上手指南:从 JavaScript 到类型安全
javascript·ubuntu·typescript
jingling55515 小时前
从零到一:用 Aholo Viewer 在浏览器里渲染 3D 高斯泼溅小熊
linux·前端·ubuntu·3d
豆奶豆豆奶17 小时前
Ubuntu 中 Codex CLI 登录失败:使用 OpenAI API Key 解决
ubuntu·codex
Better Bench17 小时前
Ubuntu 22.04系统中解决运行CC-Switch-v3.16.1-Linux-x86_64.AppImage中文乱码
linux·ubuntu·claude·claude code·cc-switch
skywalk816317 小时前
在Ubuntu安装言律并部署playground web网页
linux·运维·ubuntu
ReadVersion18 小时前
Ubuntu 22.04 设置时区
linux·运维·ubuntu
来点抹茶吗19 小时前
U-Boot、内核移植与根文件系统构建(BeagleBone Green Gateway&AM335X)
linux·嵌入式硬件·ubuntu·debian
爱就是恒久忍耐1 天前
老Ubuntu安装podman 5.x版本
linux·ubuntu·podman
奋斗的好青年1 天前
Ubuntu 修复 GRUB 引导并找回 Windows 双系统启动项(NVMe + MBR 环境)
linux·windows·ubuntu
森森-曦1 天前
在windows系统上制作启动ubuntu_22.04.5_desktop_amd64.iso启动盘
windows·ubuntu·启动盘