<?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=860" />

<title>Yubico Forum</title>
<subtitle>...visit our web-store at</subtitle>
<link href="https://forum.yubico.com/index.php" />
<updated>2012-09-07T07:17:28+01:00</updated>

<author><name><![CDATA[Yubico Forum]]></name></author>
<id>https://forum.yubico.com/feed.php?f=3&amp;t=860</id>
<entry>
<author><name><![CDATA[Klas]]></name></author>
<updated>2012-09-07T07:17:28+01:00</updated>
<published>2012-09-07T07:17:28+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=860&amp;p=3287#p3287</id>
<link href="https://forum.yubico.com/viewtopic.php?t=860&amp;p=3287#p3287"/>
<title type="html"><![CDATA[Re: OpenSSH solution without PAM nor remote API]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=860&amp;p=3287#p3287"><![CDATA[
Hello,<br /><br />Interesting solution!<br />We have a (maybe not expressed) goal that all our opensource software should be portable. If you let us know about concrete cases where the software fails on FreeBSD we'll look into fixing those issues. Either let us know here on the forums or in the issue tracker on github/google code.<br /><br />/klas<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2019">Klas</a> — Fri Sep 07, 2012 7:17 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[unicycle1]]></name></author>
<updated>2012-09-06T03:55:56+01:00</updated>
<published>2012-09-06T03:55:56+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=860&amp;p=3284#p3284</id>
<link href="https://forum.yubico.com/viewtopic.php?t=860&amp;p=3284#p3284"/>
<title type="html"><![CDATA[OpenSSH solution without PAM nor remote API]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=860&amp;p=3284#p3284"><![CDATA[
Most of the code I see everywhere is meant for Linux, sometimes OpenBSD but I hardly ever see any FreeBSD examples.<br />Pretty much everything I see fails, for various reasons, not just autoconf 1.12, so I had to come up with an alternative.<br />I've seen a couple of ForceCommand variants, but they all depend on a working connection to a remote API and again software that doesn't compile.<br />Now thanks to Phil Massyn (out here on these fora) there is a useful Perl module: Auth::Yubikey_Decrypter<br />Then in the FreeBSD ports I found p5-Auth-YubikeyDecrypter, which I've used in a perl script, that also checks for replay attacks.<br /><br />My solutions is relative simple/compact, and involves:<br /><span style="font-size: 85%; line-height: normal"><br /> - /home/john/.ssh/yubikey<br /> - /home/john/.ssh/yubikey_count<br /> - /etc/ssh/sshd_config<br /> - /etc/ssh/yubikey.sh<br /> - /etc/ssh/yubikey.pl</span><br /><br />/home/john/.ssh/yubikey contains the private id, a delimiter, and the aes<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">1d1d1d1d1d1d:ae5ae5ae5ae5ae5ae5ae5ae5ae5aeetc</div><br />/home/john/.ssh/yubikey_count contains the counter against replay attacks<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">0</div><br />/etc/ssh/sshd_config with the ForceCommand<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">AllowUsers root@192.168.0.37 john<br />PermitRootLogin yes<br />MaxAuthTries 3   <br />UseDNS no <br /><br />Match User john # ...or Match Group ykusers<br />   X11Forwarding no<br />   AllowTcpForwarding no<br />   ForceCommand /etc/ssh/yubikey.sh</div><br />the yubikey.sh script that above config refers to:<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">#!/bin/sh<br /><br /># MIND: further on this script uses OTP's of 44 chars;<br /># but this could be different in your customized OTP's<br /># Some OS's `read` command have delimiter options - for example 44 chars :)<br /><br />trap disconnect INT<br />disconnect() {<br />  kill -9 $PPID<br />  exit 1<br />  }<br /><br /># stty -echo # uncomment this (and below) if you prefer to hide the public ID<br />read -p &quot;OTP: &quot; -t 15 OTP_INPUT<br /># stty echo  # sometimes `read` has -s (silent)<br />echo; echo   # cosmetics<br /><br />OTP=$(echo &quot;$OTP_INPUT&quot; | tr -c -d a-z)<br />if &#91; $? == 0 &#93; &amp;&amp; &#91; ${#OTP} == 44 &#93;; then<br />  CNT=`cat .ssh/yubikey_count`<br />  NEW=`perl -T -- /etc/ssh/yubikey.pl $OTP $CNT`<br />  if &#91; $? == 0 &#93;; then<br />    echo $NEW &gt; .ssh/yubikey_count<br />  # clear<br />    login -f $USER<br />    disconnect<br />  fi<br />fi<br /><br />echo &quot;invalid OTP&quot; &gt; /dev/stderr<br />disconnect</div><br />the yubikey.pl code that the perl command in above script executes<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">use strict;<br />use Auth::Yubikey_Decrypter;<br /><br /># get values<br />open (FILE, &quot;&lt;&quot;, &quot;.ssh/yubikey&quot;) or die &quot;Could not open yubikey file.\n&quot;;<br />my @line = &lt;FILE&gt;;<br />chomp $line&#91;0&#93;;<br />my @ykdata = split &quot;:&quot; , $line&#91;0&#93;;<br />close FILE or die $!;<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($ARGV&#91;0&#93;,$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 /># validate:<br />if ( $ykdata&#91;0&#93; eq $secretid_hex &amp;&amp; $crc_ok == 1 &amp;&amp; $ctr32 &gt; $ARGV&#91;1&#93; ) {<br />  print $ctr32;<br />  exit 0;<br />  }<br /><br />exit 1;</div><br />Now...<br />chmod 744 /etc/ssh/yubikey.*<br />/etc/rc.d/sshd reload<br />...and do NOT logout, but see if all of the above works well by initiating a new session as user &quot;john&quot;.<br />This hopefully work for most *nix flavors.<br /><br />Yes, it's also another of the same, still; let me know if you think it can be improved, or have a good argument you think this method is useless, or maybe is better than PAM.<br />One improvement would be having the yubikey data/count files not in the user directories.<br />Another to have it working without perl, but all in sh or csh or maybe even a C binary that does the same.<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2152">unicycle1</a> — Thu Sep 06, 2012 3:55 am</p><hr />
]]></content>
</entry>
</feed>