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 密码,应该就能成功了。

相关推荐
张飞飞飞飞飞10 天前
Tmux命令使用教程
linux·服务器·ubuntu
盼小辉丶10 天前
Ubuntu极速部署OpenClaw完全指南(本地模型+DeepSeek)
linux·ubuntu·openclaw
黑白园10 天前
【环境搭建】Ubuntu安装(一)
linux·ubuntu
Moshow郑锴10 天前
Ubuntu用SDKMAN轻松管理多个Java 版本
java·ubuntu·sdkman
error:(10 天前
Ubuntu 22.04 GNOME远程桌面配置问题排查与解决全流程
linux·运维·ubuntu
Java知识技术分享10 天前
在windows上使用wsl安装Ubuntu~linux系统
linux·人工智能·windows·ubuntu
天疆说10 天前
在 Ubuntu 24.04 上安装 MATLAB R2021b
数据库·ubuntu·matlab
Clang's Blog10 天前
Ubuntu(20.04/22.04/24.04)国内环境一键安装 Docker、JDK17 和 Maven
ubuntu·docker·maven
izcll10 天前
ubuntu系统安装软件的方法
linux·运维·ubuntu
天疆说10 天前
在 Ubuntu 的 VSCode 中配置 MATLAB
vscode·ubuntu·matlab