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

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

解决办法

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

[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 配置文件,如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

# 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
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值