Decode/separate the Static Challenge format for use with PAM
Posted: Wed Jan 26, 2022 4:48 pm
I've inherited an application environment in which users are required to authenticate via Tunnelblick from their Macbooks. There is an Ubuntu box that is dedicated to running OpenVPN Server, version: OpenVPN 2.4.4 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Apr 27 2021.
There is a new requirement to implement MFA on the OpenVPN server. I've been unable to find a single authoritative source of step-by-step instructions on how to perform this implementation. Googling has provided results that either address a use case that is different to mine or suggest partial steps. None of the suggestions I've tried have worked.
In an attempt to implement MFA, I've configured a static challenge in Tunnelblick. From server.conf, I'm calling a custom script prior to invoking the PAM Login module, like so:
script-security 3
auth-user-pass-verify my-custom-script.sh via-env
plugin /usr/lib/x86_64-linux-gnu/openvpn/plugins/openvpn-plugin-auth-pam.so login login COMMONNAME password PASSWORD
Each time Tunnelblick contacts the OpenVPN server with my user credentials and my OTP from Google Authenticator, it creates an environment variable called PASSWORD whose value is a base64-encoded concatenation of the string "SRV1", my user password and the OTP using a colon as the delimiter.
SRV1:password_base64:otp_base64
My custom script reads the PASSWORD environment variable, extracts the base64-encoded password, and decodes it into plain text. I think what I need to do is to update the PASSWORD environment variable with the plain text password; but I do not know how to do this, or even if it's possible. I've aware of the existence of the pam_env module and have read its man page, but it's not clear to me how to update the value of an environment variable a value provided by a custom script.
Can anyone identify what I need to do in order to achieve my goal?
There is a new requirement to implement MFA on the OpenVPN server. I've been unable to find a single authoritative source of step-by-step instructions on how to perform this implementation. Googling has provided results that either address a use case that is different to mine or suggest partial steps. None of the suggestions I've tried have worked.
In an attempt to implement MFA, I've configured a static challenge in Tunnelblick. From server.conf, I'm calling a custom script prior to invoking the PAM Login module, like so:
script-security 3
auth-user-pass-verify my-custom-script.sh via-env
plugin /usr/lib/x86_64-linux-gnu/openvpn/plugins/openvpn-plugin-auth-pam.so login login COMMONNAME password PASSWORD
Each time Tunnelblick contacts the OpenVPN server with my user credentials and my OTP from Google Authenticator, it creates an environment variable called PASSWORD whose value is a base64-encoded concatenation of the string "SRV1", my user password and the OTP using a colon as the delimiter.
SRV1:password_base64:otp_base64
My custom script reads the PASSWORD environment variable, extracts the base64-encoded password, and decodes it into plain text. I think what I need to do is to update the PASSWORD environment variable with the plain text password; but I do not know how to do this, or even if it's possible. I've aware of the existence of the pam_env module and have read its man page, but it's not clear to me how to update the value of an environment variable a value provided by a custom script.
Can anyone identify what I need to do in order to achieve my goal?