远程到 CentOS Stream9 抛出“SSH服务器拒绝了密码,请再试一次”
今天使用vmware安装了CentOS ,在使用 XShell 连接到新安装的 CentOS Stream9 时,抛出了如下错误
解决办法
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
2、修改 sshd_config 配置文件,如下:
vi ssh_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 就可以正常连接了。