当前位置:首页>>技术文章>>内容详情

Debian 12系统中允许Root远程SSH登录解决方法

2026年09月09日
Tags:SSHDebianRoot

Debian 默认禁止 root 用户直接 SSH 登录,只允许普通用户,需要手动修改。

安全提醒:公网机器不建议直接开 root ssh,优先普通用户 + sudo;如果必须开启,请务必使用密钥登录,不要只用密码。

1. 修改 sshd 配置文件

nano /etc/ssh/sshd_config

找到这几项,修改:

# 允许root登录

PermitRootLogin yes

# 如果想用密码登录(不推荐公网)

PasswordAuthentication yes

可选值说明

PermitRootLogin prohibit-password【root 只能密钥登录,禁止密码(推荐)】

PermitRootLogin yes【密码 + 密钥都可以登录】

PermitRootLogin no【禁止 root 登录(Debian 默认)】

保存退出 nano:Ctrl+O回车,Ctrl+X


2. 重启 sshd 服务

Debian 10/11/12:

systemctl restart sshd

或者

systemctl restart ssh

检查状态:

systemctl status sshd


上一条信息:ddns-go内网穿透 实现动态IP
下一条信息:BT宝塔无法安装,panel.zip下载成功,报错下载失败!