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

相关推荐
susu10830189113 小时前
ubuntu重做系统后无法apt update
linux·运维·ubuntu
杨云龙UP5 小时前
ODA服务器RAC节点2/u01分区在线扩容操作记录及后续处理流程(Linux LVM + ext4 文件系统在线扩容操作手册)_20260307
linux·运维·服务器·数据库·ubuntu·centos
jyfool13 小时前
Ubuntu 远程桌面配置踩坑实录:从 TightVNC 到 x11vnc 的折腾之旅
linux·运维·ubuntu
嘿嘿嘿x315 小时前
MobaXterm 成功连接 Ubuntu 虚拟机
linux·运维·ubuntu
是稻香啊16 小时前
HarmonyOS6 ArkUI 触摸拦截(onTouchIntercept)全面解析与实战演示
ubuntu·华为·harmonyos·harmonyos6
生活很暖很治愈18 小时前
Linux——UDP编程&通信
linux·服务器·c++·ubuntu
炽天使32818 小时前
龙虾尝鲜记(3)——装ubuntu(续)
linux·运维·ubuntu
海兰19 小时前
利用Elastic构建欺诈检测框架
大数据·人工智能·ubuntu
岚天start19 小时前
OpenClaw大龙虾部署(国内环境)详细指南
ubuntu·openclaw·大龙虾·国内环境