如何在 Ubuntu 12.04 上使用带有 OpenVPN 服务器的 Google Authenticator

For*_*ard 9 server authentication openvpn google

我在 Ubuntu 12.04 上有一个可用的 OpenVPN 系统,我想添加 Google Authenticator 以提高安全性。

这是我当前的 openvpn 配置:

开发屯
原始UDP
端口 1096
ca ubserv04-ca.crt
证书 ubserv04.crt
密钥 ubserv04.key
dh dh1024.pem
服务器 10.10.0.0 255.255.255.0
推“重定向网关def1”
推送“路由 192.168.0.0 255.255.255.0”
推送“dhcp-option DNS 8.8.8.8”
推送“dhcp-option DNS 8.8.4.4”
漂浮
日志附加/var/log/openvpn-otp-1096-status.log

(这只是一个测试设置,我知道我应该改变它的某些方面,但现在有效。)

在客户端我有:

开发屯
客户
原始UDP
远程 my.server.fqdn 1096
解决重试无限
ca ubserv04-ca.crt
证书用户1.crt
密钥 user1.key
动词 3

上述设置工作正常:没有错误,快速,稳定。

我已经尝试了几种方法来让 Google Authenticator 运行,但我最终每次都解决了这些文章中的附带问题。我不想针对服务器的本地用户/密码数据库进行身份验证,只是我已经拥有的系统加上 Google Authenticator。

我正在运行 Google 身份验证器;我使用 apt-get install libpam-google-authenticator 安装了它,并且之前使用过它来验证 ssh 会话。效果很好,但我现在已禁用它,因为它只是一个测试服务器,并且该特定测试已完成。

请具体点。我知道我应该在服务器的 ovpn 配置中添加一个插件,并且应该向 /etc/pam.d/openvpn添加一些东西,但究竟是什么?

任何帮助将不胜感激!

/额外信息

我已经关注了这篇文章:http : //www.howtoforge.com/securing-openvpn-with-a-one-time-password-otp-on-ubuntu 而不是从源代码编译我已经安装了带有 apt 的 Google Authenticator -get 安装 libpam-google-authenticator。我也读过,但在这种情况下没有使用,这些文章:http : //www.howtogeek.com/121650/how-to-secure-ssh-with-google-authenticators-two-factor-authentication/http ://zcentric.com/2012/10/09/google-authenticator-with-openvpn-for-2-factor-auth/。我已经按照建议阅读了 PAM ;)

现在,这里有一些有趣的发展。

/etc/pam.d/openvpn 有这个:

帐户 [success=2 new_authtok_reqd=done default=ignore] pam_unix.so 
帐户 [success=1 new_authtok_reqd=done default=ignore] pam_winbind.so 
帐户要求 pam_deny.so
帐户需要 pam_permit.so
需要身份验证 pam_google_authenticator.so

根据 howto,我从 /etc/pam.d/common-account 复制了原始文件并添加了最后一行。现在,如果我注释掉最后一行,则 OpenVPN 连接成功。但是,如果最后一行没有被注释掉,/var/log/auth.log 会记录以下内容:

PAM 无法 dlopen(pam_google_authenticator.so):/lib/security/pam_google_authenticator.so:未定义符号:pam_get_item
PAM 添加错误模块:pam_google_authenticator.so

和 /var/log/openvpn-otp-1096.log 记录以下内容:

PLUGIN_CALL:插件函数 PLUGIN_AUTH_USER_PASS_VERIFY 失败,状态为 1:/usr/lib/openvpn/openvpn-auth-pam.so
TLS 身份验证错误:对等方的身份验证用户名/密码验证失败
电子使用 SSL/TLS 上下文
AUTH-PAM:背景:用户“martin”未能通过身份验证:模块未知

问题似乎出在 PAM 和 Google Authenticator 之间。

谷歌列出了其他插件的问题,但我真的找不到关于谷歌身份验证器的具体信息。

For*_*ard 4

好吧,谷歌是我的朋友。

我这样做了:

# apt-get purge libpam-google-authenticator
# 下载 https://code.google.com/p/google-authenticator/downloads/list
# apt-get 安装 libpam-dev

将其添加到 Makefile 中,紧接在许可证之后:

LDFLAGS="-lpam"

然后

# 制作
# 进行安装
# 服务 openvpn 重新启动

另外,请确保 /home/username/.google_authenticator 除了要使用它的用户的读取权限外没有任何其他权限。

现在我需要输入我的用户名,即我在服务器上的本地用户名(我的 shell 帐户)作为我的 OpenVPN 用户名,并输入 Google Authenticator 6 位数代码作为密码。

现在可以了。

谢谢大家的宝贵时间:)

(如何将这篇文章标记为已解决?我只需编辑主题标题吗?)