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

相关推荐
KivenMitnick3 小时前
Claude Code--Ubuntu Linux超详细配置教程(附每步的可能报错及解决方法)
linux·运维·ubuntu
冰冷的希望5 小时前
【系统】非虚拟机,物理机安装Ubuntu教程,Windows与Linux(Ubuntu)双系统共存!
linux·windows·ubuntu·系统架构·vmware·双系统·pe系统
水月天涯7 小时前
Mac系统下制作 Ubuntu镜像(小白教程)
linux·ubuntu·macos
乌白云7 小时前
windows11下利用wsl2安装Ubuntu-24.04
linux·ubuntu·wsl2
坐吃山猪7 小时前
TypeScript编程04-函数
javascript·ubuntu·typescript
BIBI20498 小时前
VirtualBox 7.x 安装 Ubuntu 24 及增强功能配置、克隆虚拟机教程
linux·windows·ubuntu·环境搭建·安装教程·最佳实践·virtualbox
weixin_462901979 小时前
HICKPI主板h618 Ubuntu / Armbian 镜像 SD安装
linux·运维·ubuntu
llkk星期五9 小时前
ubuntu(24.04)下wayland显示界面带来的影响
linux·ubuntu
地下核武19 小时前
Ubuntu 24.04 在线安装 Qt 6.10.2 后 Qt Creator 无法启动问题记录与解决
linux·qt·ubuntu
chinesegf19 小时前
ubuntu建虚拟环境制作docker容器
linux·ubuntu·docker