【问题标题】:OpenVPN: Authentication Failed?OpenVPN:身份验证失败?
【发布时间】:2019-10-14 22:42:21
【问题描述】:

当我在 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=*****```
==============================================================

【问题讨论】:

    标签: server-side vpn openvpn


    【解决方案1】:

    我使用了不同的方法,虽然在生产中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
    

    现在创建一个客户端文件并使用您的密码导入和连接,但这是我的堆栈,因为我不想提供客户端文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-24
      • 2017-11-27
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 2014-05-23
      相关资源
      最近更新 更多