Ubuntu(友帮拓/乌班图) Type `help' to learn how to use Xshell prompt. Linux系统 运维技术

admin 2025-05-26 348

1、第一步,修改root密码

sudo passwd root

在Ubuntu系统中使用Xshell通过root账户连接SSH时遇到密码被拒绝的问题,即使密码正确,可能是由于以下原因导致的。请按照以下步骤排查和解决:

1. 检查root账户的SSH登录权限
默认情况下,Ubuntu禁止root直接通过SSH登录。需确认是否已修改此设置:

sudo nano /etc/ssh/sshd_config 

找到以下参数并修改:

PermitRootLogin yes  # 确保此项为"yes"(若为"prohibit-password",需改为"yes")
PasswordAuthentication yes  # 确保密码认证开启 

#PubkeyAuthentication no

检查其他配置文件
除了 sshd_config,还需要检查其他相关配置文件,例如 sshd_config.d 目录下的文件。

sudo grep -r "PasswordAuthentication" /etc/ssh/ 

修改/etc/ssh/sshd_config.d/60-cloudimg-settings.conf

sudo nano /etc/ssh/sshd_config.d/60-cloudimg-settings.conf

把文件的PasswordAuthentication on改为yes

PasswordAuthentication yes  # 确保密码认证开启 

温馨提示: 主要是Proxmox PVE安装 Ubuntu Cloud Images 镜像会出现这个问题。
Ubuntu Cloud Images 镜像下载地址:https://cloud-images.ubuntu.com/releases/

保存后重启SSH服务:

sudo systemctl restart sshd 

检查防火墙规则:

sudo ufw status

临时关闭防火墙测试:

sudo ufw disable

确保SSH端口(默认22)开放:

sudo ufw allow 22/tcp

给特定用户读写权限

sudo setfacl -m u:username:rw /etc/ssh/sshd_config 

 

 

最新回复 (0)
全部楼主
    • MSDN,我告诉你(中文站)
      2
        登录 注册 获取赞助码
返回