Linux-密钥改成密码登录SSH[2026/9/11 11:48:55]
 

查看: 402  |  回复: 0
 Linux-密钥改成密码登录SSH
楼主
发表于 2026年5月18日 16:45 

为 root 设置密码

sudo passwd root

修改 SSH 配置,允许密码登录(修改可以用 宝塔SSH的文件夹功能进入/etc/ssh找sshd_config复制到记事本,然后查找修改,更方便)

# 编辑 SSH 配置文件
sudo vim /etc/ssh/sshd_config

找到以下配置项,修改为:

# 将 PasswordAuthentication 改为 yes
PasswordAuthentication yes

# 如果存在 ChallengeResponseAuthentication,也改为 yes(可能没有)
ChallengeResponseAuthentication yes

# 如果要允许 root 直接登录(可选)
PermitRootLogin yes

说明:

PasswordAuthentication yes:允许密码登录

PermitRootLogin yes:允许 root 用户直接登录(如果需要的话)

重启 SSH 服务使配置生效

# Debian/Ubuntu 系统
sudo systemctl restart sshd


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2026 MaNongKu.com