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

相关推荐
钟良堂14 小时前
Ubuntu 20.04 部署 ORB_SLAM3 完整流程与踩坑总结
linux·运维·ubuntu
牢姐与蒯1 天前
Linux进程(四).进程优先级以及进程切换,进程调度
linux·运维·服务器·ubuntu
奈斯先生Vector2 天前
从“能调用”到“可替换”:Coze 多模型 API 编排层设计指南
linux·运维·人工智能·ubuntu·平面·ios
郴墨2 天前
Ubuntu 24.04 配置大量ip及ssh远程
tcp/ip·ubuntu·ssh
光电的一只菜鸡2 天前
ubuntu之坑(二十)——VMware虚拟机系统无法正常进入如何处理
linux·运维·ubuntu
笨笨饿2 天前
#111_关于FreeRTOS面试的一些题目
linux·ubuntu·面试·职场和发展·centos·rtos
lajidecrd2 天前
Ubuntu 24.04 LTS安装
linux·运维·ubuntu
jing.wang_20252 天前
制作最小Linux(Ubuntu)系统
linux·嵌入式硬件·ubuntu·dsp开发
JasonHuan11233 天前
Hyper-V-三台虚拟机安装启动使用完全指南
linux·ubuntu·hyper-v·虚拟机