问题:
现在要求远程登录到服务器时,需要增加一个Google的动态验证码,增加一层认证,以提高安全性。
方法:
安装教程我是参考这个博客:安装教程,只要按着走下来,肯定能够安装成功。但是我遇到了以下的报错:
Aug 8 23:02:03 node2 sshd(pam_google_authenticator)[2161]: Invalid verification code Aug 8 23:02:06 node2 sshd[2159]: error: PAM: Cannot make/remove an entry for the specified session for root from 192.168.10.161 Aug 8 23:03:12 node2 sshd(pam_google_authenticator)[2163]: Invalid verification code Aug 8 23:03:12 node2 sshd(pam_google_authenticator)[2163]: Secret file "/root/.google_authenticator" changed while trying to use scratch code Aug 8 23:03:15 node2 sshd[2159]: error: PAM: Cannot make/remove an entry for the specified session for root from 192.168.10.161 Aug 8 23:03:20 node2 sshd(pam_google_authenticator)[2170]: Invalid verification code Aug 8 23:03:23 node2 sshd[2159]: error: PAM: Cannot make/remove an entry for the specified session for root from 192.168.10.161 Aug 9 14:06:40 node2 sshd[2154]: Received signal 15; terminating. Aug 9 14:06:40 node2 sshd[2259]: Server listening on 0.0.0.0 port 22. Aug 9 14:06:40 node2 sshd[2259]: Server listening on :: port 22. Aug 9 14:06:59 node2 sshd[2262]: Address 192.168.10.161 maps to localhost, but this does not map back to the address - POSSIBLE BRE
1
2
3
4
5
6
7
8
9
10
11
|
Aug
8
23
:
02
:
03
node2
sshd
(
pam_google_authenticator
)
[
2161
]
:
Invalid
verification
code
Aug
8
23
:
02
:
06
node2
sshd
[
2159
]
:
error
:
PAM
:
Cannot
make
/
remove
an
entry
for
the
specified
session
for
root
from
192.168.10.161
Aug
8
23
:
03
:
12
node2
sshd
(
pam_google_authenticator
)
[
2163
]
:
Invalid
verification
code
Aug
8
23
:
03
:
12
node2
sshd
(
pam_google_authenticator
)
[
2163
]
:
Secret
file
"/root/.google_authenticator"
changed
while
trying
to
use
scratch
code
Aug
8
23
:
03
:
15
node2
sshd
[
2159
]
:
error
:
PAM
:
Cannot
make
/
remove
an
entry
for
the
specified
session
for
root
from
192.168.10.161
Aug
8
23
:
03
:
20
node2
sshd
(
pam_google_authenticator
)
[
2170
]
:
Invalid
verification
code
Aug
8
23
:
03
:
23
node2
sshd
[
2159
]
:
error
:
PAM
:
Cannot
make
/
remove
an
entry
for
the
specified
session
for
root
from
192.168.10.161
Aug
9
14
:
06
:
40
node2
sshd
[
2154
]
:
Received
signal
15
;
terminating
.
Aug
9
14
:
06
:
40
node2
sshd
[
2259
]
:
Server
listening
on
0.0.0.0
port
22.
Aug
9
14
:
06
:
40
node2
sshd
[
2259
]
:
Server
listening
on
::
port
22.
Aug
9
14
:
06
:
59
node2
sshd
[
2262
]
:
Address
192.168.10.161
maps
to
localhost
,
but
this
does
not
map
back
to
the
address
-
POSSIBLE
BRE
|
第一时间想到是手机和服务器的时间不一致,导致的动态密码错误,所以执行:date -s "2017-11-14 15:44:20"
,对服务器进行时间同步,但是去认证还是报以上的错误,最后注意到服务器的时间是
Tue Nov 14 16:52:02 EST 2017
但是我的电脑本机时间是:
2017年11月14日 星期二 16时39分49秒 CST
两者有CST和EST的区别,百度一查, 原来是时区的问题,通过此博客:时间修改大法 :
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 路径里面有很多是去的文件。文件里面不知道是啥设置。然后再reboot 。
重启后对时区进行了设置,然后再同步时间:ntpdate pool.ntp.org
。这时候再去用动态密码登录,就成功登录了
指点:
当遇到问题时,一定要学会去看系统的日志,本次我就是查看日志:tail -n 10 /var/log/recure
,才找到具体的原因。