检查系统的log文件:/var/log/auth.log 发现如下的记录

May  7 03:41:09 ubuntu02-X785-G30 sshd[2598]: User xxx from 10.2.89.240 not allowed because not listed in AllowUsers
May  7 03:41:09 ubuntu02-X785-G30 sshd[2598]: input_userauth_request: invalid user xxx [preauth]
May  7 03:41:13 ubuntu02-X785-G30 sshd[2598]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=10.2
.89.240  user=xxx
May  7 03:41:15 ubuntu02-X785-G30 sshd[2598]: Failed password for invalid user xxx from 10.2.89.240 port 60225 ssh2

解决办法
检查sshd的配置文件 /etc/ssh/sshd_config,发现里面指定了AllowUsers,而登录的用户名并没有在里面,因此不能登录。所以将sshd_config文件的这一行注释掉或者将用户名也加入进去就能解决。

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐