家里服务器 CentOS 8.2 安装 Google-Authenticator

家里服务器 CentOS 8.2 安装 Google-Authenticator

1
https://www.versca.cn/?p=1170

1. 时区不对,时间不对 的解决办法

1
https://www.versca.cn/?p=6159

2. 安装过程 ./configure 时会出现个小问题.

1
2
3
4
5
6
config.status: error: in `/root/google-authenticator-libpam':
config.status: error: Something went wrong bootstrapping makefile fragments
    for automatic dependency tracking.  Try re-running configure with the
    '--disable-dependency-tracking' option to at least be able to build
    the package (albeit without support for automatic dependency tracking).
See `config.log' for more details

解决办法: 改成如下代码

1
./configure --disable-dependency-tracking

3. 登陆时无法登陆,原因是 google_authenticator 代码错误

3-1. 查看失败的原因:

1
cat /var/log/secure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Jul 26 07:55:24 192 sshd(pam_google_auth)[40171]: Invalid verification code for root
Jul 26 07:55:24 192 sshd(pam_google_auth)[40171]: Failed to create tempfile "/root/.google_authenticator~gXhiDK": Permission denied
Jul 26 07:55:24 192 sshd(pam_google_auth)[40171]: Failed to update secret file "/root/.google_authenticator": Permission denied
Jul 26 07:55:28 192 sshd[40169]: Connection closed by authenticating user root 192.168.122.1 port 54228 [preauth]
Jul 26 07:55:53 192 sshd(pam_google_auth)[40199]: Accepted google_authenticator for root
Jul 26 07:55:53 192 sshd(pam_google_auth)[40199]: Failed to create tempfile "/root/.google_authenticator~DevKgS": Permission denied
Jul 26 07:55:53 192 sshd(pam_google_auth)[40199]: Failed to update secret file "/root/.google_authenticator": Permission denied
Jul 26 07:56:01 192 sshd[40197]: error: PAM: Authentication failure for root from 192.168.122.1
Jul 26 07:56:10 192 sshd(pam_google_auth)[40216]: Accepted google_authenticator for root
Jul 26 07:56:10 192 sshd(pam_google_auth)[40216]: Failed to create tempfile "/root/.google_authenticator~FvTGv7": Permission denied
Jul 26 07:56:10 192 sshd(pam_google_auth)[40216]: Failed to update secret file "/root/.google_authenticator": Permission denied
Jul 26 07:56:19 192 sshd[40197]: error: PAM: Authentication failure for root from 192.168.122.1
Jul 26 07:56:47 192 gdm-password][40253]: pam_unix(gdm-password:session): session opened for user root by (uid=0)
Jul 26 07:56:50 192 polkitd[907]: Registered Authentication Agent for unix-session:4 (system bus name :1.240 [/usr/bin/gnome-shell], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
Jul 26 07:56:58 192 gdm-launch-environment][1308]: pam_unix(gdm-launch-environment:session): session closed for user gdm
Jul 26 07:56:58 192 polkitd[907]: Unregistered Authentication Agent for unix-session:c1 (system bus name :1.76, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)

3-2. 外网找到答案:

1
SELinux is preventing /usr/sbin/sshd from create access on the file .google_authenticator~gXhiDK

3-3. 解决办法: 关闭SELinux

1
vi /etc/selinux/config
1
SELINUX=disabled
1
reboot        //重启电脑

4. 然后再登陆就成功.

5. 把 图形界面换成 代码界面

1
systemctl set-default multi-user.target

6. 安装zerotier

1
https://www.versca.cn/?p=1661

Leave a Reply