<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
<link rel="self" type="application/atom+xml" href="https://forum.yubico.com/feed.php?f=3&amp;t=868" />

<title>Yubico Forum</title>
<subtitle>...visit our web-store at</subtitle>
<link href="https://forum.yubico.com/index.php" />
<updated>2013-04-07T23:26:24+01:00</updated>

<author><name><![CDATA[Yubico Forum]]></name></author>
<id>https://forum.yubico.com/feed.php?f=3&amp;t=868</id>
<entry>
<author><name><![CDATA[Tom]]></name></author>
<updated>2013-01-25T11:36:10+01:00</updated>
<published>2013-01-25T11:36:10+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=868&amp;p=3486#p3486</id>
<link href="https://forum.yubico.com/viewtopic.php?t=868&amp;p=3486#p3486"/>
<title type="html"><![CDATA[Re: OpenVPN solution without PAM nor remote API]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=868&amp;p=3486#p3486"><![CDATA[
Thank you for this post.<br /><br />Could you please edit it following the [Guidelines] ?<br /><br />I'd like to make it sticky.<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2195">Tom</a> — Fri Jan 25, 2013 11:36 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[unicycle]]></name></author>
<updated>2013-04-07T23:26:24+01:00</updated>
<published>2012-10-08T17:54:37+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=868&amp;p=3316#p3316</id>
<link href="https://forum.yubico.com/viewtopic.php?t=868&amp;p=3316#p3316"/>
<title type="html"><![CDATA[[HOW-TO] - OpenVPN solution without PAM nor remote API]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=868&amp;p=3316#p3316"><![CDATA[
<strong>Description:</strong><br />This describes how to enable authentication on OpenVPN, with custom OTP's, but without PAM modules nor online API calls,<br />using a static file &quot;username&quot;.txt (chmod r) and for the anti-replay attack counter &quot;username&quot;.cnt (chmod rw).<br /><br /><strong>Requirements:</strong><br />OpenVPN<br />Auth::Yubikey_Decrypter perl module<br /><br />In openvpn's server.conf I point to a perl script (named ovpn-yk-val.pl).<br />Your config file could have a zillion differences according to your needs, but the 3 lines about the perl is what matters here:<div class="codetitle"><b>Code:</b></div><div class="codecontent">local 1.2.3.4<br />port 1194<br />proto udp<br />dev tun<br />#<br />ca   /usr/local/etc/openvpn/keys/ca.crt<br />cert /usr/local/etc/openvpn/keys/server.crt<br />key  /usr/local/etc/openvpn/keys/server.key # This file should be kept secret<br />dh   /usr/local/etc/openvpn/keys/dh1024.pem<br />#<br />server 10.8.0.0 255.255.255.0<br />#<br />ifconfig-pool-persist ipp.txt<br />#<br />topology subnet<br />push &quot;dhcp-option DNS 99.99.99.99&quot;<br />push &quot;redirect-gateway def1 bypass-dhcp&quot;<br />#<br />script-security 3<br />username-as-common-name<br />auth-user-pass-verify &quot;/usr/local/etc/openvpn/ovpn-yk-val.pl&quot; via-env<br />#<br />keepalive 10 120<br />comp-lzo<br />#<br />persist-key<br />persist-tun<br />status /var/log/openvpn-status.log<br />log-append /var/log/openvpn.log<br />verb 3<br />#<br /># client-to-client<br /># max-clients 25<br /></div><br /><br />and ovpn-yk-val.pl itself looks like this:<div class="codetitle"><b>Code:</b></div><div class="codecontent">#!/usr/bin/perl -T<br />use strict;<br />use Auth::Yubikey_Decrypter;<br /><br /># $ENV{&quot;common_name&quot;};<br /># $ENV{&quot;username&quot;};<br /># $ENV{&quot;password&quot;};<br /><br />my $usr = $ENV{&quot;username&quot;};<br />$usr =~ m/^(&#91;a-zA-Z0-9&#93;+)$/;<br />exit !(length($1) &gt; 0);<br />my $credsfile = &quot;/usr/local/etc/openvpn/$1.txt&quot;;<br />my $countfile = &quot;/usr/local/etc/openvpn/$1.cnt&quot;;<br />exit !(-e $credsfile);<br />exit !(-e $countfile);<br /><br /># get values<br />open (FILE1, &quot;&lt;&quot;, $credsfile) or die &quot;Could not open yubikey credential file.\n&quot;;<br /><br />my @line = &lt;FILE1&gt;;<br />chomp $line&#91;0&#93;;<br />my @ykdata = split &quot;:&quot; , $line&#91;0&#93;;<br />close FILE1 or die $!;<br /><br />my $otp = $ENV{&quot;password&quot;};<br />$otp =~ m/^(&#91;a-zA-Z0-9&#93;+)$/;<br />exit !(length($1) &gt; 0);<br /><br /># decrypt:<br />my ($publicID,$secretid_hex,$counter_dec,$timestamp_dec,$session_use_dec,$random_dec,$crc_dec,$crc_ok) =<br />      Auth::Yubikey_Decrypter::yubikey_decrypt($1,$ykdata&#91;1&#93;);<br /><br /># prepare to check replay attacks<br />my $ctr32 = (($counter_dec &amp; 0x7fff) &lt;&lt; 8) + $session_use_dec;<br /><br />open (FILE2, &quot;+&gt;&quot;, $countfile) or die &quot;Could not open yubikey counter file.\n&quot;;<br />my $counter = do { local $/; &lt;FILE2&gt; };<br />$counter =~ m/^(&#91;0-9&#93;+)$/;<br /><br /># validate:<br />if ( $ykdata&#91;0&#93; eq $secretid_hex &amp;&amp; $crc_ok == 1 &amp;&amp; $ctr32 &gt; $1 ) {<br />  truncate(FILE2, 0);<br />  print FILE2 $ctr32;<br />  close FILE2 or die $!;<br />  exit 0;<br />  }<br /><br />close FILE2 or die $!;<br />exit 1;</div><br /><br /><em>identity</em>:<br />In this example there is a &quot;/usr/local/etc/openvpn/$1.txt&quot; and a &quot;/usr/local/etc/openvpn/$1.cnt&quot;.<br />You'll need to add the Private Identity in for example /usr/local/etc/openvpn/john.txt, such that the perl sript can validate against it.<br /><em>counter:</em><br />And you need to have a 0 (zero) in the counter file, named /usr/local/etc/openvpn/john.cnt (or whatever path you changed above sample code to) - this is to detect and prevent replay attacks.<br /><br />When (re)starting OpenVPN now should accept OTP's as credentials.<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2176">unicycle</a> — Mon Oct 08, 2012 5:54 pm</p><hr />
]]></content>
</entry>
</feed>