<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Ubuntu on The Network Stack</title>
    <link>https://thenetworkstack.com/tags/ubuntu/</link>
    <description>Recent content in Ubuntu on The Network Stack</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 16 Oct 2017 17:07:40 +0000</lastBuildDate>
    <atom:link href="https://thenetworkstack.com/tags/ubuntu/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Troubleshooting Disk Space Usage</title>
      <link>https://thenetworkstack.com/troubleshooting-disk-space-usage/</link>
      <pubDate>Mon, 16 Oct 2017 17:07:40 +0000</pubDate>
      <guid>https://thenetworkstack.com/troubleshooting-disk-space-usage/</guid>
      <description>&lt;p&gt;A couple years ago, my coworker wrote a great post on finding disk space issues in Linux and how to resolve them. Helped me out this weekend when a critical server was having issues, so wanted to post it here:&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://www.randomlyexpressed.com/diagnosing-linux-disk-usage/&#34;&gt;http://www.randomlyexpressed.com/diagnosing-linux-disk-usage/&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;For future reference &lt;em&gt;(after reading the post above)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Show filesystem usage:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;~$ df -h
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Show &lt;em&gt;all&lt;/em&gt; files/directories consuming space:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;~$ du -kx / &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; sort -nr &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; more
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Show directories in current location:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>A couple years ago, my coworker wrote a great post on finding disk space issues in Linux and how to resolve them. Helped me out this weekend when a critical server was having issues, so wanted to post it here:</p>
<p><a href="http://www.randomlyexpressed.com/diagnosing-linux-disk-usage/">http://www.randomlyexpressed.com/diagnosing-linux-disk-usage/</a></p>
<hr>
<p><strong>For future reference <em>(after reading the post above)</em></strong></p>
<p>Show filesystem usage:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">~$ df -h
</span></span></code></pre></div><p>Show <em>all</em> files/directories consuming space:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">~$ du -kx / <span class="p">|</span> sort -nr <span class="p">|</span> more
</span></span></code></pre></div><p>Show directories in current location:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">~$ du -hc <span class="p">|</span> sort -h
</span></span><span class="line"><span class="cl">~$ du -hc --max<span class="o">=</span><span class="m">1</span> <span class="p">|</span> sort -h <span class="c1">#This limits your directory listing to one level</span>
</span></span></code></pre></div><p>List files in directory:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">~$ ls -larth
</span></span></code></pre></div><p>List files in directory sorted by size, ascending:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">~$ ls -lSrh
</span></span></code></pre></div><p>List and then delete any .log file older than 7 days:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">~$ find . -type f -name <span class="s2">&#34;*.log&#34;</span> -mtime +7 -print -exec rm -fr <span class="o">{}</span> <span class="se">\;</span>
</span></span></code></pre></div><p>Another easy way to reclaim space by removing unused dependencies:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">~$ apt-get autoremove
</span></span></code></pre></div>]]></content:encoded>
    </item>
    <item>
      <title>SSH with Duo MFA and Active Directory</title>
      <link>https://thenetworkstack.com/ssh-with-duo-mfa-and-active-directory/</link>
      <pubDate>Wed, 30 Aug 2017 23:03:22 +0000</pubDate>
      <guid>https://thenetworkstack.com/ssh-with-duo-mfa-and-active-directory/</guid>
      <description>&lt;p&gt;Duo has thorough &lt;a href=&#34;https://duo.com/docs/duounix&#34;&gt;documentation&lt;/a&gt; for adding MFA to your SSH sessions, but there are a couple additional steps needed to also integrate with Active Directory. This post will go through the installation for both Duo and Active Directory for Ubuntu 16.04. For other Linux distros, the Duo documentation linked above has you covered.&lt;br&gt;
\&lt;/p&gt;
&lt;h4 id=&#34;system-components&#34;&gt;&lt;strong&gt;System components:&lt;/strong&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Ubuntu 16.04 server&lt;/li&gt;
&lt;li&gt;Duo MFA account&lt;/li&gt;
&lt;li&gt;Duo Unix package&lt;/li&gt;
&lt;li&gt;Centify Express for Active Directory integration&lt;br&gt;
\&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;duo-installation&#34;&gt;&lt;strong&gt;Duo Installation:&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;Install OpenSSL development headers and libraries:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Duo has thorough <a href="https://duo.com/docs/duounix">documentation</a> for adding MFA to your SSH sessions, but there are a couple additional steps needed to also integrate with Active Directory. This post will go through the installation for both Duo and Active Directory for Ubuntu 16.04. For other Linux distros, the Duo documentation linked above has you covered.<br>
\</p>
<h4 id="system-components"><strong>System components:</strong></h4>
<ul>
<li>Ubuntu 16.04 server</li>
<li>Duo MFA account</li>
<li>Duo Unix package</li>
<li>Centify Express for Active Directory integration<br>
\</li>
</ul>
<h4 id="duo-installation"><strong>Duo Installation:</strong></h4>
<p>Install OpenSSL development headers and libraries:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">apt-get install libssl-dev libpam-dev -y
</span></span></code></pre></div><p>Add Duo repository and install duo-unix package:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">echo</span> <span class="s1">&#39;deb http://pkg.duosecurity.com/Ubuntu xenial main&#39;</span> <span class="p">|</span> tee /etc/apt/sources.list.d/duosecurity.list
</span></span><span class="line"><span class="cl">curl -s https://duo.com/APT-GPG-KEY-DUO <span class="p">|</span> apt-key add -
</span></span><span class="line"><span class="cl">apt-get update
</span></span><span class="line"><span class="cl">apt-get install duo-unix
</span></span></code></pre></div><p>Edit <strong>/etc/duo/pam_duo.conf</strong> with your integration key, secret key, and API host. You can find these values in the <a href="https://admin.duosecurity.com">Duo Administration page</a> for your &ldquo;UNIX Application&rdquo;.</p>
<pre tabindex="0"><code>[duo]
; Duo integration key
ikey = XXXXXXXXXXXXXXXXXXXXXXX
; Duo secret key
skey = XXXXXXXXXXXXXXXXXXXXXXX
; Duo API host
host = XXXXXXXXXXXXXXXXXXXXXXX
; Send command for Duo Push authentication
;pushinfo = yes
</code></pre><h4 id="centrify-installation"><strong>Centrify Installation:</strong></h4>
<p>First, edit <strong>/etc/ssh/sshd_config</strong> so that ChallengeResponseAuthentication is set to &ldquo;yes&rdquo;</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Change to yes to enable challenge-response passwords (beware issues with</span>
</span></span><span class="line"><span class="cl"><span class="c1"># some PAM modules and threads)</span>
</span></span><span class="line"><span class="cl">ChallengeResponseAuthentication yes
</span></span></code></pre></div><p>Download, unzip, and install Centrify Express:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">wget https://downloads.centrify.com/products/centrify-suite/2017-update-1/centrify-suite-2017.1-deb7-x86_64.tgz
</span></span><span class="line"><span class="cl">tar -xvzf centrify-suite-2017.1-deb7-x86_64.tgz
</span></span><span class="line"><span class="cl">./install-express.sh
</span></span></code></pre></div><p>Go through the installation script to connect to your Active Directory environment:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">You can <span class="nb">type</span> Q at any prompt to quit the installation and <span class="nb">exit</span>
</span></span><span class="line"><span class="cl">the script without making any changes to your environment.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">How <span class="k">do</span> you want to proceed? <span class="o">(</span>E<span class="p">|</span>S<span class="p">|</span>X<span class="p">|</span>C<span class="p">|</span>Q<span class="o">)</span> <span class="o">[</span>X<span class="o">]</span>: X
</span></span><span class="line"><span class="cl">Do you want to <span class="k">continue</span> to install in Express mode? <span class="o">(</span>C<span class="p">|</span>Y<span class="p">|</span>Q<span class="p">|</span>N<span class="o">)</span> <span class="o">[</span>Y<span class="o">]</span>:Y
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Do you want to run adcheck to verify your AD environment? <span class="o">(</span>Q<span class="p">|</span>Y<span class="p">|</span>N<span class="o">)</span> <span class="o">[</span>Y<span class="o">]</span>:Y
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Please enter the Active Directory domain to check <span class="o">[</span>company.com<span class="o">]</span>: your-domain.com
</span></span><span class="line"><span class="cl">Join an Active Directory domain? <span class="o">(</span>Q<span class="p">|</span>Y<span class="p">|</span>N<span class="o">)</span> <span class="o">[</span>Y<span class="o">]</span>:Y
</span></span><span class="line"><span class="cl">    Enter the Active Directory domain to join <span class="o">[</span>your-domain.com<span class="o">]</span>:
</span></span><span class="line"><span class="cl">    Enter the Active Directory authorized user <span class="o">[</span>administrator<span class="o">]</span>: your-admin
</span></span><span class="line"><span class="cl">    Enter the password <span class="k">for</span> the Active Directory user:
</span></span><span class="line"><span class="cl">    Enter the computer name <span class="o">[</span>server-name<span class="o">]</span>:
</span></span><span class="line"><span class="cl">    Enter the container DN <span class="o">[</span>Computers<span class="o">]</span>:
</span></span><span class="line"><span class="cl">    Enter the name of the domain controller <span class="o">[</span>auto detect<span class="o">]</span>:
</span></span><span class="line"><span class="cl">Reboot the computer after installation? <span class="o">(</span>Q<span class="p">|</span>Y<span class="p">|</span>N<span class="o">)</span> <span class="o">[</span>Y<span class="o">]</span>: Y
</span></span></code></pre></div><p>After the server restarts, you should be able to login with your Active Directory credentials via SSH, but you are not prompted for Duo MFA. To support this, we need to edit <strong>/etc/pam.d/common-auth</strong> as follows:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># lines inserted by Centrify Direct Control { CentrifyDC 5.4.1-455 }</span>
</span></span><span class="line"><span class="cl"><span class="c1">#auth   sufficient      pam_centrifydc.so</span>
</span></span><span class="line"><span class="cl"><span class="c1">#auth   requisite       pam_centrifydc.so deny</span>
</span></span><span class="line"><span class="cl">auth    requisite       pam_centrifydc.so
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># here are the per-package modules (the &#34;Primary&#34; block)</span>
</span></span><span class="line"><span class="cl"><span class="c1">#auth   [success=1 default=ignore]      pam_unix.so nullok_secure</span>
</span></span><span class="line"><span class="cl">auth    requisite       pam_unix.so nullok_secure
</span></span><span class="line"><span class="cl">auth  <span class="o">[</span><span class="nv">success</span><span class="o">=</span><span class="m">1</span> <span class="nv">default</span><span class="o">=</span>ignore<span class="o">]</span> /lib64/security/pam_duo.so
</span></span></code></pre></div><p>In both sections, I commented out the existing config and added the necessary lines so that pam_duo is used after a successful pam_centrifydc authentication.</p>
<p>Next, we need to edit <strong>/etc/pam.d/sshd</strong> and comment out &ldquo;@include common-auth&rdquo; so we can add the Centrify and Duo PAM modules (but we don&rsquo;t need pam_unix):</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Standard Un*x authentication.</span>
</span></span><span class="line"><span class="cl"><span class="c1">#@include common-auth</span>
</span></span><span class="line"><span class="cl">auth    requisite       pam_centrifydc.so
</span></span><span class="line"><span class="cl">auth    <span class="o">[</span><span class="nv">success</span><span class="o">=</span><span class="m">1</span> <span class="nv">default</span><span class="o">=</span>ignore<span class="o">]</span>      /lib64/security/pam_duo.so
</span></span><span class="line"><span class="cl">auth    requisite       pam_deny.so
</span></span><span class="line"><span class="cl">auth    required        pam_permit.so
</span></span></code></pre></div><p>You should be able to SSH to the server with your Active Directory credentials, and then be prompted for Duo MFA (assuming you have a Duo account that matches your AD username)<br>
\</p>
<h4 id="active-directory-group-restriction"><strong>Active Directory Group Restriction:</strong></h4>
<p>You may also want to restrict SSH access to users in a certain Active Directory group. This can be done with two lines in <strong>/etc/ssh/sshd_config</strong> at the end of the config, after &ldquo;UsePAM yes&rdquo;:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">UsePAM yes
</span></span><span class="line"><span class="cl"><span class="c1">#########</span>
</span></span><span class="line"><span class="cl">UseDNS no
</span></span><span class="line"><span class="cl">AllowGroups root your-group-name
</span></span></code></pre></div><p>Be sure to add the &lsquo;root&rsquo; group so that you can still manage your server with the root account if needed. Restart SSH and your group restriction will be in effect:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">service ssh restart
</span></span></code></pre></div>]]></content:encoded>
    </item>
    <item>
      <title>Duo Security - HA Radius Servers</title>
      <link>https://thenetworkstack.com/duo-security-ha-radius-servers/</link>
      <pubDate>Thu, 19 Nov 2015 01:49:07 +0000</pubDate>
      <guid>https://thenetworkstack.com/duo-security-ha-radius-servers/</guid>
      <description>&lt;p&gt;If you are using Duo Security MFA (highly recommended), you may want high-availability for your Duo Radius servers.  Duo doesn&amp;rsquo;t currently have a &amp;ldquo;supported&amp;rdquo; solution for this, but &lt;strong&gt;keepalived&lt;/strong&gt; worked great after a quick call to support.  This is also assuming you have followed Duo&amp;rsquo;s instructions to install their radius server (found &lt;a href=&#34;https://www.duosecurity.com/docs/radius&#34;&gt;here&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;First, install keepalived (basic instructions for Ubuntu 14.04:  &lt;a href=&#34;https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html&#34;&gt;https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;Radius server #1 config:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;vrrp_instance VIP_1 {
 state MASTER
 interface eth0
 virtual_router_id 100
 priority 101
 preempt_delay 30
 advert_int 1
authentication {
 auth_type PASS
  auth_pass password
  }
virtual_ipaddress  {
10.0.0.1 dev eth0
 }
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Radius server #2 config:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>If you are using Duo Security MFA (highly recommended), you may want high-availability for your Duo Radius servers.  Duo doesn&rsquo;t currently have a &ldquo;supported&rdquo; solution for this, but <strong>keepalived</strong> worked great after a quick call to support.  This is also assuming you have followed Duo&rsquo;s instructions to install their radius server (found <a href="https://www.duosecurity.com/docs/radius">here</a>)</p>
<p>First, install keepalived (basic instructions for Ubuntu 14.04:  <a href="https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html">https://raymii.org/s/tutorials/Keepalived-Simple-IP-failover-on-Ubuntu.html</a>)</p>
<p>Radius server #1 config:</p>
<pre tabindex="0"><code>vrrp_instance VIP_1 {
 state MASTER
 interface eth0
 virtual_router_id 100
 priority 101
 preempt_delay 30
 advert_int 1
authentication {
 auth_type PASS
  auth_pass password
  }
virtual_ipaddress  {
10.0.0.1 dev eth0
 }
}
</code></pre><p>Radius server #2 config:</p>
<pre tabindex="0"><code>vrrp_instance VIP_1 {
 state BACKUP
 interface eth0
 virtual_router_id 100
 priority 100
 preempt_delay 30
 advert_int 1
authentication {
 auth_type PASS
  auth_pass password
  }
virtual_ipaddress  {
10.0.0.1 dev eth0
 }
}
</code></pre><p>After this was completed, keepalived was up and running, and I could ping/ssh to the VIP, <em><strong>but</strong></em>, Duo was not responding to radius requests on the VIP!? After trying several different options, I called into Duo Support to see if anything could be done.  The support engineer and I discovered that the &ldquo;interface=&rdquo; command in authproxy.cfg could be used to bind to an IP address other than the default eth0 address.  This is what I added to the top of the authproxy.cfg for Duo Radius:</p>
<pre tabindex="0"><code>[main]
interface=10.0.0.1

[ad_client]
...etc
</code></pre><p>After I restarted the duoauthproxy service, radius requests completed successfully using the VIP and my HA solution is complete!  Testing shows 1-second failover times between both servers with keepalived.</p>
<p>View the VIP assigned to eth0:</p>
<pre tabindex="0"><code>ip addr show eth0
</code></pre>]]></content:encoded>
    </item>
    <item>
      <title>Linux Packet Capture</title>
      <link>https://thenetworkstack.com/linux-packet-capture/</link>
      <pubDate>Wed, 17 Sep 2014 01:55:42 +0000</pubDate>
      <guid>https://thenetworkstack.com/linux-packet-capture/</guid>
      <description>&lt;p&gt;If you need to debug traffic going to a linux server or appliance, you can use tcpdump to generate a pcap file you can analyze in wireshark.&lt;/p&gt;
&lt;p&gt;For example, ssh into the server, and use the following command:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;tcpdump -s0 port 80 and host 192.168.1.10 -wDebugTraffic.pcap
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will capture all traffic coming into port 80 from host 192.168.1.10 and saved as file DebugTraffic.pcap&lt;/p&gt;
&lt;p&gt;You can then use an ftp program (like WinSCP) to grab the file and analyze it in wireshark.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>If you need to debug traffic going to a linux server or appliance, you can use tcpdump to generate a pcap file you can analyze in wireshark.</p>
<p>For example, ssh into the server, and use the following command:</p>
<pre tabindex="0"><code>tcpdump -s0 port 80 and host 192.168.1.10 -wDebugTraffic.pcap
</code></pre><p>This will capture all traffic coming into port 80 from host 192.168.1.10 and saved as file DebugTraffic.pcap</p>
<p>You can then use an ftp program (like WinSCP) to grab the file and analyze it in wireshark.</p>
<p>Here is a great resource for tcpdump commands:  <a href="http://packetlife.net/media/library/12/tcpdump.pdf">http://packetlife.net/media/library/12/tcpdump.pdf</a></p>
]]></content:encoded>
    </item>
  </channel>
</rss>
