CentOS6でSSHでログインできなかった理由

原因ですが、なんと、アカウントがExpireしていました。
自分が設定したサーバーではないので、なぜExpireしていたのかはアレですが、まあ、こんなこともあるのかと。

1.SSHでログインできないとの報告あり。

2.SSHの接続元のIP制限やパスワードが違っているわけではなかった。iptablesのせいでもない。

3./var/log/secureには
sshd[24094]: reverse mapping checking getaddrinfo for xxx.xxx.ne.jp [xxx.xxx.xxx.xxx] failed - POSSIBLE BREAK-IN ATTEMPT!
sshd[24094]: pam_unix(sshd:account): account hogehoge has expired (account expired)
sshd[24094]: Failed password for hogehoge from xxx.xxx.xxx.xxx port 51331 ssh2
sshd[24095]: fatal: Access denied for user hogehoge by PAM account configuration
とあったのだが、2行目の「account expired」を見落としていて、なぜログイン出来ないのか暫く悩む。

4./etc/pam.d/sshd に account required pam_access.so はなかったので、/etc/security/access.conf の設定の問題ではない。

5.ローカルでsshのテストをしてみると、
ssh -v -v -v hogehoge@localhost

OpenSSH_x.xp1, OpenSSL x.x.x-fips xx xxx xxxx
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
...
The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is xxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
debug2: bits set: 497/1024
...
hogehoge@localhost's password:
debug3: packet_send2: adding 48 (len 65 padlen 15 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug3: Wrote 144 bytes for a total of 1253
debug3: input_userauth_banner
Your account has expired; please contact your system administrator
Connection closed by ::1

ここでやっと「Expire」と気づく。

6.ほんまか?と次のコマンドで確認。
# chage -l hogehoge
Last password change : Dec 23, 2017
Password expires : never
Password inactive : never
Account expires : May 31, 2016
Minimum number of days between password change : -1
Maximum number of days between password change : -1
Number of days of warning before password expires : -1

7.本当にExpireしていたので、その解除と、パスワードの再設定を行う。
# usermod -L -e '' hogehooge
# passwd hogehoge

これで、SSHでログインできるようになりましたとさ。

ぐっどらっこ。