Linux-密钥改成密码登录SSH - 第1页 - 码农库
 
首页 /服务器与软件/Linux
 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


 
全部回复(0)
首页 | 电脑版 |