sshd:如果 MaxAuthTries 大于 3,则将被忽略

sshd:如果 MaxAuthTries 大于 3,则将被忽略

我使用的是 CentOS v7,我尝试设置,MaxAuthTries 6但似乎不起作用。我使用的是 PAM,因此UsePAM yes设置了属性。我不确定是错误还是其他原因阻止了身份验证尝试超过 3 次。

在日志中,我得到了以下结果

[root@webserver ~]# sshd -T | grep -i 'pam\|authtries\|gracetime'
usepam yes
logingracetime 600
maxauthtries 6
[root@webserver ~]# tail -f /var/log/secure
Mar 26 12:04:41 webserver systemd: Stopping OpenSSH server daemon...
Mar 26 12:04:41 webserver systemd: Starting OpenSSH server daemon...
Mar 26 12:04:41 webserver systemd: PID file /var/run/sshd.pid not readable (yet?) after start.
Mar 26 12:04:41 webserver sshd[2308]: Server listening on 0.0.0.0 port 22.
Mar 26 12:04:41 webserver sshd[2308]: Server listening on 0.0.0.0 port 22.
Mar 26 12:04:41 webserver sshd[2308]: Server listening on :: port 22.
Mar 26 12:04:41 webserver sshd[2308]: Server listening on :: port 22.
Mar 26 12:04:41 webserver polkitd[687]: Unregistered Authentication Agent for unix-process:2301:105272 (system bus name :1.23, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Mar 26 12:04:41 webserver polkitd[687]: Unregistered Authentication Agent for unix-process:2301:105272 (system bus name :1.23, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Mar 26 12:04:41 webserver systemd: Started OpenSSH server daemon.
Mar 26 12:05:16 webserver unix_chkpwd[2318]: password check failed for user (test)
Mar 26 12:05:16 webserver unix_chkpwd[2318]: password check failed for user (test)
Mar 26 12:05:16 webserver sshd[2316]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=gateway  user=test
Mar 26 12:05:16 webserver sshd[2316]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=gateway  user=test
Mar 26 12:05:18 webserver sshd[2316]: Failed password for test from 192.168.124.1 port 48936 ssh2
Mar 26 12:05:18 webserver sshd[2316]: Failed password for test from 192.168.124.1 port 48936 ssh2
Mar 26 12:05:20 webserver unix_chkpwd[2319]: password check failed for user (test)
Mar 26 12:05:20 webserver unix_chkpwd[2319]: password check failed for user (test)
Mar 26 12:05:22 webserver sshd[2316]: Failed password for test from 192.168.124.1 port 48936 ssh2
Mar 26 12:05:22 webserver sshd[2316]: Failed password for test from 192.168.124.1 port 48936 ssh2
Mar 26 12:05:25 webserver unix_chkpwd[2320]: password check failed for user (test)
Mar 26 12:05:25 webserver unix_chkpwd[2320]: password check failed for user (test)
Mar 26 12:05:27 webserver sshd[2316]: Failed password for test from 192.168.124.1 port 48936 ssh2
Mar 26 12:05:27 webserver sshd[2316]: Failed password for test from 192.168.124.1 port 48936 ssh2
Mar 26 12:05:27 webserver sshd[2316]: Connection closed by 192.168.124.1 [preauth]
Mar 26 12:05:27 webserver sshd[2316]: Connection closed by 192.168.124.1 [preauth]
Mar 26 12:05:27 webserver sshd[2316]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=gateway  user=test
Mar 26 12:05:27 webserver sshd[2316]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=gateway  user=test

答案1

客户端上有一个选项(ssh_config),NumberOfPasswordPrompts默认设置为 3。这就是我无法超过 3 次尝试的原因。

NumberOfPasswordPrompts
             Specifies the number of password prompts before giving up.  The argument to this keyword must be an integer.  The default is 3.

相关内容