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

相关推荐
鲁Q同志8 小时前
VMware虚拟机安装Ubuntu22
ubuntu·vmware
BENA ceic13 小时前
Java进阶-在Ubuntu上部署SpringBoot应用
java·spring boot·ubuntu
小周技术驿站14 小时前
Linux 权限管理细节详解
linux·运维·服务器·ubuntu·centos
红茶要加冰15 小时前
如何安装ubuntu-24.04-live-server-amd64系统
linux·运维·ubuntu
molihuan17 小时前
最新VMware Ubuntu 1分钟极速安装 植物人教程
linux·ubuntu
70asunflower17 小时前
Ubuntu `tree` 命令完全指南:让目录结构一目了然
linux·数据库·ubuntu
bksczm18 小时前
Linux之基础开发工具(Ubuntu)之apt 、vim
linux·ubuntu·php
程序员老邢18 小时前
【技术底稿 23】Ollama + Docker + Ubuntu 部署踩坑实录:网络通了,参数还在调
java·经验分享·后端·ubuntu·docker·容器·milvus
俩个逗号。。19 小时前
Ubuntu 动画全部消失
linux·ubuntu
天疆说19 小时前
在 Ubuntu 22.04 上安装 Ghostty 终端
linux·运维·ubuntu