原 使用ssh连接报错Permission denied
现象
1 2 3 4 5 6 7 8 9 10 | [root@test /]# su - gpadmin Last login: Mon Aug 5 04:23:02 UTC 2024 on pts/4 Last failed login: Mon Aug 5 04:28:41 UTC 2024 from 192.92.0.27 on ssh:notty There were 6 failed login attempts since the last successful login. [gpadmin@test ~]$ [gpadmin@test ~]$ [gpadmin@test ~]$ ssh test gpadmin@test's password: Permission denied, please try again. gpadmin@test's password: |
此时文件/var/log/secure
输出:
1 2 3 4 5 6 7 8 9 10 11 12 13 | [root@test soft]# tailf /var/log/secure Aug 5 04:28:07 test su: pam_unix(su-l:session): session closed for user gpadmin Aug 5 04:28:10 test su: pam_unix(su-l:session): session closed for user gpadmin Aug 5 04:28:12 test su: pam_unix(su-l:session): session closed for user gpadmin Aug 5 04:28:24 test polkitd[274]: Registered Authentication Agent for unix-process:2822251:354665314 (system bus name :1.13575 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) Aug 5 04:28:32 test polkitd[274]: Unregistered Authentication Agent for unix-process:2822251:354665314 (system bus name :1.13575, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus) Aug 5 04:28:40 test sshd[2822327]: User gpadmin from 192.92.0.27 not allowed because not listed in AllowUsers Aug 5 04:28:40 test sshd[2822327]: input_userauth_request: invalid user gpadmin [preauth] Aug 5 04:28:41 test sshd[2822327]: error: Could not get shadow information for NOUSER Aug 5 04:28:41 test sshd[2822327]: Failed password for invalid user gpadmin from 192.92.0.27 port 43148 ssh2 Aug 5 04:28:51 test sshd[2822327]: Connection closed by 192.92.0.27 port 43148 [preauth] Aug 5 04:30:40 test su: pam_unix(su-l:session): session opened for user gpadmin by (uid=0) |
解决
1 2 3 4 5 6 7 8 9 | [root@test /]# cat /etc/ssh/sshd_config | grep Allow #AllowAgentForwarding yes #AllowTcpForwarding yes # AllowTcpForwarding no AllowUsers root lhr [root@test /]# vi /etc/ssh/sshd_config [root@test /]# [root@test /]# systemctl restart sshd [root@test /]# |
修改后可以正常登陆了: