RFC: Yubikey authentication for OpenVPN.
Hi all,
No further comments or requests on the openvpn-users lists. Reposting here for further criticism / comments :)
I did have one thought though, do I need to put any kind of banner at the top of the script as a 'maintainer' or such?
I have attached this script for comment to be considered for inclusion in the contrib section of openvpn to use the Yubico Yubicloud authentication for the Yubikey OTP.
Place the script in /etc/openvpn and configure as follows:
script-security 2
client-connect /etc/openvpn/yubikey-auth-tokens
auth-user-pass-verify /etc/openvpn/yubikey-auth-tokens via-file
client-cert-not-required
username-as-common-name
Right now, this requires 'reneg-sec 0' be set in the openvpn server config file due to some issues in handling auth tokens in various configurations - however hopefully when this gets fixed, it will keep the connection running with an auth-token after the initial authentication by OTP.
Edit the yubikey-auth-tokens script and edit the %yubikeys hash with your list of usernames and associated yubikey IDs.
Happy to receive feedback on the script, its operation, or implementation.
Signature · 4 lines
Steven Haigh 📧 [email protected]... 💻 http://www.crc.id.au 📞 +61 (3) 9001 6090 📱 0412 935 897
Quoted 11 lines · AEST Selva Nair
Quoted 5 lines · Steven Haigh
script-security 2
client-connect/etc/openvpn/yubikey-auth-tokens
auth-user-pass-verify/etc/openvpn/yubikey-auth-tokensvia-file
client-cert-not-required
username-as-common-nameWhy the last two entries? client-cert-not-required is not something one should encourage users to do. Apart from that yubikey verification may have to be done asynchronously (using deferred auth), else connections to all clients will stall during each verification which may take some time.
In my setup, I use username + OTP. I don't provide a client cert to each client.
I wonder if I could use $ENV{'username'} in client-connect instead to make this a little more consistent. This would remove the need to 'username-as- common-name' to be set.
How would a client cert as well as username/OTP affect this flow? Is that expected to be verified by client-connect or another script? or is the cert validation done elsewhere - by openvpn in this case I guess?
(apologies, mail client fat finger - I sent this reply to openvpn-users first time around!)
Signature · 4 lines
Steven Haigh 📧 [email protected]... 💻 http://www.crc.id.au 📞 +61 (3) 9001 6090 📱 0412 935 897
Quoted 21 lines · AEST Steven Haigh
Quoted 7 lines · AEST Selva Nair
Quoted 5 lines · Steven Haigh
script-security 2
client-connect/etc/openvpn/yubikey-auth-tokens
auth-user-pass-verify/etc/openvpn/yubikey-auth-tokensvia-file
client-cert-not-required
username-as-common-nameQuoted 5 lines
Why the last two entries? client-cert-not-required is not something one should encourage users to do. Apart from that yubikey verification may have
to be done asynchronously (using deferred auth), else connections to all clients will stall during each verification which may take some time.In my setup, I use username + OTP. I don't provide a client cert to each client.
I wonder if I could use $ENV{'username'} in client-connect instead to make this a little more consistent. This would remove the need to 'username-as- common-name' to be set.
Quoted 6 lines
How would a client cert as well as username/OTP affect this flow? Is that expected to be verified by client-connect or another script? or is the cert validation done elsewhere - by openvpn in this case I guess?
(apologies, mail client fat finger - I sent this reply to openvpn-users first time around!)
Ok - in reviewing this, I've removed the use of the username in the first part of the token as generated in the 'client-connect' portion of the script. As we don't get a username in the client-connect, I've added a 64 char random string to the first part of the token. While this doesn't help crypto wise - it assists in making it a little more difficult to predict.
The driving part behind this is to try and not have a static preset key used in the generation of the auth-token. Instead, we use system specific and connection specific things instead.
The up-shot of this is that it removes the need to use the 'username-as- common-name' directive in the server config.
It would then be up to the server operator if they wished to use client-cert- not-required and just utilise username + OTP or issue client certs and use cert + username + OTP.
I'll post a v2 of this script when the client side issues are taken care of within openvpn for auth-tokens and am able to test the full loop around.
Signature · 4 lines
Steven Haigh 📧 [email protected]... 💻 http://www.crc.id.au 📞 +61 (3) 9001 6090 📱 0412 935 897
Quoted 31 lines · AEST David Sommerseth
Quoted 7 lines · Steven Haigh
Hi all,
No further comments or requests on the openvpn-users lists. Reposting here for further criticism / comments :)
I did have one thought though, do I need to put any kind of banner at the top of the script as a 'maintainer' or such?
I have actually quickly tested this script, and it works fine with my yubikey test token.
One remark which needs to be highlighted is that this implementation uses single-factor OTP authentication. But the OTP code used in this mode is fairly long, so it is reasonably secure (and still far better than static human passwords). The token codes are generated using keying material which is pre-loaded to a Yubikco server - which essentially provides the authentication via a HTTPS request.
I think this is a reasonably good starting point.
What is needed is to have some kind of copyright header in the top of the file (as a "larger" comment block). This copyright needs to carry a license which is compatible to GPLv2. You can put yourself as the copyright holder, which implicitly puts you as a maintainer and contact person if there are issues.
What would be good in addition is to either inside this Perl script or as a README file describing what you need to do to get this working. Reasonable "talking points" could be:
Quoted 8 lines
- Configuring your Yubikey token (at least point at Yubikey docs)
- Emphasize that the token must be registered at YubiCloud (or the validation server being used)
- Highlight what needs to be changed in the Perl script to enable new users.For more advanced topics ... using your own Yubikey validation server, like using this one: <https://developers.yubico.com/yubikey-val/>
I've taken this onboard. I've added the following text to the top of the script:
# Copyright (c) 2017 Steven Haigh <[email protected]...> # https://www.crc.id.au
# Licensed under the GPL version 2
# PURPOSE: This script automatically can be used to handle authentication
# of Yubikey enabled accounts for One Time Password (OTP) use.
# INSTALL NOTES:
# Place this script in /etc/openvpn and use the following in your server
# configuration file:
# script-security 2 # client-connect /etc/openvpn/yubikey-auth-tokens # auth-user-pass-verify /etc/openvpn/yubikey-auth-tokens via-file # client-cert-not-required
# If you wish to use Client Certificate + username + OTP for authentication
# exclude the 'client-cert-not-required' option and use any other guide on # how to manage the certificate side of authentication.
# USAGE NOTES:
# To set up your Yubikey in Yubico OTP mode, use the personalisation tool
# in "Yubico OTP mode", and choose 'Quick' setup. Be sure to generate new # values and then use the 'Upload to Yubico' to activate your key within # the Yubico Validation Server.
# Edit the %yubikeys definition below to include your chosen username and
# the first 12 digits of one of your Yubico OTP passwords.
# If you have a Yubico API ID, you may substitute the $yubico_id value
# for your own, or use the default '16'.
# ------------------ CODE BEGINS HERE -----------------
Signature · 4 lines
Steven Haigh 📧 [email protected]... 💻 http://www.crc.id.au 📞 +61 (3) 9001 6090 📱 0412 935 897