大网数据广告活动
服务器运维问答

sshd: MaxAuthTries is ignored if it is greated than 3

· 52CE 我爱测

I am using CentOS v7, and I tried to set MaxAuthTries 6 though this doesn't seem to work. I am using PAM so the property UsePAM yes is set. I am not sure if it is a bug or something else blocking the auth tries to more than 3. In…

问题原文

原帖链接 · etcshad0vv · CC BY-SA 3.0

I am using CentOS v7, and I tried to set MaxAuthTries 6 though this doesn't seem to work. I am using PAM so the property UsePAM yes is set. I am not sure if it is a bug or something else blocking the auth tries to more than 3.

In the logs, I am getting the below results

[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

已采纳解答

原帖链接 · etcshad0vv · CC BY-SA 3.0

There is an option on client side(ssh_config), NumberOfPasswordPrompts which by default is set to 3. This is why I couldn't go beyond 3 attempts.

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。