远程到 CentOS Stream9 抛出“SSH服务器拒绝了密码,请再试一次”

本文将介绍怎样解决使用 XShell 远程连接到 CentOS Stream9 时,抛出“SSH服务器拒绝了密码,请再试一次”错误。

今天在使用 XShell 连接到新安装的 CentOS Stream9 时,抛出了如下错误:

远程到 CentOS Stream9 抛出“SSH服务器拒绝了密码,请再试一次”

解决办法

(1)进入到 /etc/ssh/ 目录,命令如下:

[root@localhost ~]# cd /etc/ssh/
[root@localhost ssh]# ll
total 600
-rw-r--r--. 1 root root     578094 Feb 22 20:32 moduli
-rw-r--r--. 1 root root       1921 Feb 22 20:32 ssh_config
drwxr-xr-x. 2 root root         28 Apr  2 22:28 ssh_config.d
-rw-------. 1 root root       3689 Apr  2 22:31 sshd_config
drwx------. 2 root root         28 Apr  2 21:11 sshd_config.d
-rw-r-----. 1 root ssh_keys    492 Apr  2 21:30 ssh_host_ecdsa_key
-rw-r--r--. 1 root root        162 Apr  2 21:30 ssh_host_ecdsa_key.pub
-rw-r-----. 1 root ssh_keys    387 Apr  2 21:30 ssh_host_ed25519_key
-rw-r--r--. 1 root root         82 Apr  2 21:30 ssh_host_ed25519_key.pub
-rw-r-----. 1 root ssh_keys   2578 Apr  2 21:30 ssh_host_rsa_key
-rw-r--r--. 1 root root        554 Apr  2 21:30 ssh_host_rsa_key.pub

(2)修改 sshd_config 配置文件,如下:

# possible, but leave them commented.  Uncommented options override the
# default value.

# To modify the system-wide sshd configuration, create a  *.conf  file under
#  /etc/ssh/sshd_config.d/  which will be automatically included below
Include /etc/ssh/sshd_config.d/*.conf

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

在该配置文件中添加“PermitRootLogin yes”配置选项,yes 表示运行 root 账号进行远程登录,false 则不允许远程登录。

(3)重启系统,再次使用 XShell 就可以正常连接了。

成熟不是人的心变老,而是泪在眼眶里打转还能微笑。
0 不喜欢
说说我的看法 -
全部评论(
没有评论
关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号