server-side - OpenVPN:身份验证失败?
问题描述
当我在 server.conf 中使用插件进行身份验证时,身份验证将不起作用,但没有它,不存在的用户也可以进行身份验证。
我在服务器 conf 和 clinet 中添加了以下几行
Commands in the server.conf file
================================
mode server
tls-server
plugin /usr/lib64/openvpn/plugin/lib/openvpn-auth-pam.so login
key-direction 0
================================
Commands in the client file
=================================
port 1194
proto udp
dev tun
nobind
key-direction 1
redirect-gateway def1
tls-version-min 1.2
auth SHA256
auth-user-pass
tls-client
remote-cert-tls server
resolv-retry infinite
persist-key
persist-tun
verb 3
===============================
Logs:
==============================================================
PLUGIN_CALL: POST /usr/lib64/openvpn/plugin/lib/openvpn-auth-pam.so/PLUGIN_AUTH_USER_PASS_VERIFY status=1
PLUGIN_CALL: plugin function PLUGIN_AUTH_USER_PASS_VERIFY failed with status 1: /usr/lib64/openvpn/plugin/lib/openvpn-auth-pam.so
TLS Auth Error: Auth Username/Password verification failed for peer
Authenticate/Decrypt packet error: bad packet ID (may be a replay): [ #7 / time = (1559124952) Wed May 29 10:15:52 2019 ] -- see the man page entry for --no-replay and --replay-window for more info or silence this warning with --mute-replay-warnings
TLS Error: incoming packet authentication failed from [AF_INET6]::ffff:
openvpn[10420]: pam_unix(login:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost= user=*****```
==============================================================
解决方案
我使用了不同的方法,虽然在生产plugin /usr/lib64/openvpn/plugin/lib/openvpn-auth-pam.so login
中是推荐的方式,但我已经采用了一个 shell 脚本并获得了身份验证,但请记住这是危险的。
/etc/openvpn/server.conf
在文件中添加以下行
--verify-cline-cert none
script-security 2
auth-user-pass-verify /etc/openvpn/example.sh via-file
现在创建一个/etc/openvpn/example.sh
包含以下内容的文件
!/bin/bash
echo "started"
username=`head -1 $1`
password=`tail -1 $1`
if grep "$username:$password" $0.passwd > /dev/null 2>&1
then
exit 0
else
if grep "$username" $0.passwd > /dev/null 2>&1
then
echo "auth-user-pass-verify: Wrong password entered for user '$username'"
else
echo "auth-user-pass-verify: Unknown user '$username'"
fi
exit 1
fi
现在/etc/openvpn/example.sh.passwd
使用以下内容创建用户名和密码
userone:securepassworduserone
usertwo:securepasswordusertwo
现在创建一个客户端文件并使用您的密码导入和连接,但这是我的堆栈,因为我不想提供客户端文件。
推荐阅读
- laravel - 从 centos 托管的 laravel 应用程序连接 db2 数据库
- android - 设计时视图属性作为图像问题
- docker - 将“hostpath PV”挂载到 pod 时保留 pod 目录文件
- excel - 将内容来自表格的字符串与工作表名称进行比较,如果相同则删除
- javascript - 故事书中未显示的模态
- php - Symfony 4:JSON 响应中未转义的斜线
- python - 如何生成具有颜色格式的 Python 输出文件?
- python - AttributeError:“DiscordClient”对象没有属性“edit_role”
- angular - 需要在 Angular 项目中运行 serve 命令,但找不到项目定义
- linux - 召唤其他脚本的菜单