<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>disflux blog</title>
	<atom:link href="http://blog.disflux.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.disflux.org</link>
	<description>UNIX and other musings</description>
	<lastBuildDate>Sun, 12 Feb 2012 23:08:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>FreeBSD Disk Performance on a Cloud VPS with vfs.read_max</title>
		<link>http://blog.disflux.org/2012/02/freebsd-disk-performance-on-a-cloud-vps-with-vfs-read_max/</link>
		<comments>http://blog.disflux.org/2012/02/freebsd-disk-performance-on-a-cloud-vps-with-vfs-read_max/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 21:47:16 +0000</pubDate>
		<dc:creator>phrac</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[tuning]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://blog.disflux.org/?p=43</guid>
		<description><![CDATA[After getting setup on a new VPS running in the cloud via ToggleBox, I was browsing the Knowledge Base and came across this interesting tidbit: Our SAN is optimized for random IO as that is more typical in a hosting environment. Enabling readahead under Linux will greatly increase sequential reads. blockdev --setra 16384 /dev/xvda1 Replace [...]]]></description>
			<content:encoded><![CDATA[<p>After getting setup on a new VPS running in the cloud via <a href="http://www.togglebox.com/" title="ToggleBox">ToggleBox</a>, I was browsing the Knowledge Base and came across this interesting tidbit:</p>
<blockquote><p>Our SAN is optimized for random IO as that is more typical in a hosting environment. Enabling readahead under Linux will greatly increase sequential reads. </p>
<p><code>blockdev --setra 16384 /dev/xvda1</code></p>
<p>Replace /dev/xvda1 with /dev/sda1 on older distributions.  You can add this command to /etc/rc.local to make it persistent across reboots.</p></blockquote>
<p>Because I am running FreeBSD 8.2-STABLE, the above tweaks do not apply to me. However, FreeBSD does have a vfs.read_max kernel tunable that behaves in much the same way. The default setting is very low, being set at a value of 8.</p>
<p>Some benchmarks of various settings I tried using bonnie (-s 8192) because I have 4GB RAM on this machine:</p>
<p><code>vfs.read_max=8 (default):</p>
<p>File './Bonnie.1614', size: 8589934592<br />
Writing with putc()...done<br />
Rewriting...done<br />
Writing intelligently...done<br />
Reading with getc()...done<br />
Reading intelligently...done<br />
Seeker 1...Seeker 2...Seeker 3...start 'em...done...done...done...<br />
---------------------Sequential Output-------- ---Sequential Input-- --Random--<br />
---------------Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---<br />
Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU<br />
......8192 49868 24.6 50477 10.1 15540  4.0 33310 18.2 40572  7.0 235.9  1.5</code></p>
<p><code>vfs.read_max=128</p>
<p>File './Bonnie.2275', size: 8589934592<br />
Writing with putc()...done<br />
Rewriting...done<br />
Writing intelligently...done<br />
Reading with getc()...done<br />
Reading intelligently...done<br />
Seeker 1...Seeker 2...Seeker 3...start 'em...done...done...done...<br />
---------------------Sequential Output-------- ---Sequential Input-- --Random--<br />
---------------Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---<br />
Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU<br />
.......8192 48717 24.0 52936 10.9 15433  3.9 58900 33.9 66069 13.0 406.7  2.4</code></p>
<p>As you can see, sequential input and random seeks and reads are much, much faster with a higher read_max value set, while writes remain about the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.disflux.org/2012/02/freebsd-disk-performance-on-a-cloud-vps-with-vfs-read_max/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encode Video for Android using Handbrake</title>
		<link>http://blog.disflux.org/2011/03/handbrake-video-encoding-one-liner-android-handbrake/</link>
		<comments>http://blog.disflux.org/2011/03/handbrake-video-encoding-one-liner-android-handbrake/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 23:37:49 +0000</pubDate>
		<dc:creator>phrac</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[multimedia]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://blog.disflux.org/?p=35</guid>
		<description><![CDATA[Here's a quick one-liner to encode videos for playback on Android phones using Handbrake: HandBrakeCLI -i "$1" -o "$2" -I -e x264 -q 0.61 -a 1 -E faac -B 128 -R 44.1 -6 stereo -f mp4 -X 800 -m -x level=30:bframes=0:cabac=0:ref=2:vbv-maxrate=1500:vbv-bufsize=2000:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1:psy:0:psy-rd=0,0:subq=6:subme=6:no-dct-decimate=0:8x8dct=0:trellis=0:weightb=0 &#160;]]></description>
			<content:encoded><![CDATA[<p>Here's a quick one-liner to encode videos for playback on Android phones using <a href="http://handbrake.fr/">Handbrake</a>:</p>
<p><code>HandBrakeCLI -i "$1" -o "$2" -I -e x264 -q 0.61 -a 1 -E faac -B 128 -R 44.1 -6 stereo -f mp4 -X 800 -m -x level=30:bframes=0:cabac=0:ref=2:vbv-maxrate=1500:vbv-bufsize=2000:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1:psy:0:psy-rd=0,0:subq=6:subme=6:no-dct-decimate=0:8x8dct=0:trellis=0:weightb=0</code></p>
<p style="text-align: center;">&nbsp;</p>
<p><a href="http://blog.disflux.org/wp-content/uploads/2011/03/movieshot.png"><img src="http://blog.disflux.org/wp-content/uploads/2011/03/movieshot.png" alt="" title="movieshot" width="800" height="480" class="aligncenter size-full wp-image-36" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.disflux.org/2011/03/handbrake-video-encoding-one-liner-android-handbrake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blocking SSH Brute Force attempts with OpenBSD&#8217;s  pf</title>
		<link>http://blog.disflux.org/2011/03/blocking-ssh-brute-force-attempts-with-openbsds-pf/</link>
		<comments>http://blog.disflux.org/2011/03/blocking-ssh-brute-force-attempts-with-openbsds-pf/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 14:35:50 +0000</pubDate>
		<dc:creator>phrac</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.disflux.org/?p=24</guid>
		<description><![CDATA[As anyone with a public facing IP address knows, you will eventually see massive amounts of bruteforce attempts on your SSH port by script kiddies attempting to gain access: ... Mar 15 12:02:34 prime sshd[6518]: Invalid user nagios from 50.23.135.86 Mar 15 12:02:35 prime sshd[6520]: Invalid user nagios from 50.23.135.86 Mar 15 12:02:36 prime sshd[6522]: [...]]]></description>
			<content:encoded><![CDATA[<p>As anyone with a public facing IP address knows, you will eventually see massive amounts of bruteforce attempts on your SSH port by script kiddies attempting to gain access:<br />
<code><br />
...<br />
Mar 15 12:02:34 prime sshd[6518]: Invalid user nagios from 50.23.135.86<br />
Mar 15 12:02:35 prime sshd[6520]: Invalid user nagios from 50.23.135.86<br />
Mar 15 12:02:36 prime sshd[6522]: Invalid user weblogic from 50.23.135.86<br />
Mar 15 12:02:37 prime sshd[6524]: Invalid user weblogic from 50.23.135.86<br />
Mar 15 12:02:38 prime sshd[6526]: Invalid user weblogic from 50.23.135.86<br />
Mar 15 12:02:39 prime sshd[6528]: Invalid user ftp1 from 50.23.135.86<br />
Mar 15 12:02:39 prime sshd[6530]: Invalid user ftp1 from 50.23.135.86<br />
Mar 15 12:02:40 prime sshd[6532]: Invalid user ftp1 from 50.23.135.86<br />
...<br />
</code></p>
<p>While there are several methods for blocking these attempts, such as <a href="http://denyhosts.sourceforge.net/">denyhosts</a>, I was looking for a simpler solution. I am already running <a href="http://www.openbsd.org/faq/pf/">OpenBSD's pf</a> on my FreeBSD VPS, so a solution using pf seemed like the way to go. While FreeBSD has a handbook entry on how to accomplish this, I found a site that <a href="http://johan.fredin.info/openbsd/block_ssh_bruteforce.html">explains how to do this with two simple rules</a>.</p>
<p>The first rule, which should be early in your rules configuration will block all inbound traffic from hosts that are in the <code>ssh-bruteforce</code> table:</p>
<p><code>block drop in quick on $ext_if from &lt;ssh-bruteforce&gt;</code></p>
<p>The rule says "block all packets from any hosts in the ssh-bruteforce table without processing any more filter rules." This rule is useless without anything in the <code>ssh-bruteforce</code> table, so the next rule is where the magic happens:<br />
<code><br />
pass in on $ext_if proto tcp from any to ($ext_if) port ssh \<br />
	flags S/SA keep state \<br />
	(max-src-conn-rate 3/30, overload <ssh-bruteforce> flush global)<br />
</code></p>
<p>This rule uses pf's <code>max-src-conn-rate</code> to start populating the <code>ssh-bruteforce</code> table.  This rule tells pf to allow inbound connections on port 22 but if any host tries to connect more than 3 times in 30 seconds, add that host to the <code>ssh-bruteforce</code> table, effectively blocking that host from connecting at all. Examining the table after a few hours or days, we see:<br />
<code><br />
prime# pfctl -t ssh-bruteforce -T show<br />
   24.222.76.98<br />
   58.68.231.29<br />
   60.191.121.170<br />
   61.180.240.17<br />
   88.191.63.71<br />
...<br />
</code></p>
<p>This table can fill up fast if you have a lot of bruteforce attempts, so a cron script to flush that table at times may be necessary.</p>
<p>Of course you can tune your rule for different time lengths and number of connections, but be careful not to lock yourself out by setting the values too low. To an attacker it appears as if your server disappeared and they will move on to the next target and leave you alone. I think this is a clean, elegant solution, and works well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.disflux.org/2011/03/blocking-ssh-brute-force-attempts-with-openbsds-pf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH through an ISA proxy with NTLM Authentication</title>
		<link>http://blog.disflux.org/2011/03/ssh-through-an-isa-proxy-with-ntlm-authentication/</link>
		<comments>http://blog.disflux.org/2011/03/ssh-through-an-isa-proxy-with-ntlm-authentication/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 14:26:17 +0000</pubDate>
		<dc:creator>phrac</dc:creator>
				<category><![CDATA[proxy]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.disflux.org/?p=3</guid>
		<description><![CDATA[The problem arose as I was trying to connect to my home computer and VPS via SSH at work and was blocked by an ISA proxy with NTLM authentication. Although programs like puTTY can use a proxy for connections, they cannot authenticate against NTLM, effectively blocking outbound connections. After searching around on Google for a [...]]]></description>
			<content:encoded><![CDATA[<p>The problem arose as I was trying to connect to my home computer and VPS via SSH at work and was blocked by an ISA proxy with <a title="NTLM" href="http://en.wikipedia.org/wiki/NTLM">NTLM</a> authentication. Although programs like <a title="puTTY" href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">puTTY </a>can use a proxy for connections, they cannot authenticate against NTLM, effectively blocking outbound connections.</p>
<p>After searching around on Google for a while, I ran across a <a title="NTLM Authorization proxy" href="http://ntlmaps.sourceforge.net/">NTLM Authorization proxy</a> written in python that authenticates to the ISA proxy and creates a local proxy for your programs to use. To get it running, you simply edit a small configuration file, enter your relevant details, and then run the server.  It runs in a Windows command prompt and creates a proxy on the port you specified in the configuration file.</p>
<p>After you get the proxy server running, getting puTTY to connect is a breeze. Simply tell putty to connect via your local proxy, and it will instantly go through the ISA proxy, connecting to your outside host.</p>
<p><a href="http://blog.disflux.org/wp-content/uploads/2011/03/putty-proxy.png"><img class="size-full wp-image-14 aligncenter" title="putty-proxy" src="http://blog.disflux.org/wp-content/uploads/2011/03/putty-proxy.png" alt="putty NTLM proxy configuration" width="466" height="448" /></a></p>
<p>The next problem I encountered after getting the proxy setup was the ISA's refusal to allow a secure connection on port 22. The error message I got was:</p>
<p><code>Proxy error: 502 Proxy Error ( The specified Secure Sockets Layer (SSL) port is not allowed. ISA Server is not configured to allow SSL requests from this port. Most Web browsers use port 443 for SSL requests. )</code></p>
<p>Basically, I couldn't go through the proxy on the standard SSH port 22. A simple sshd_config tweak fixed that:</p>
<p><code>/etc/ssh/sshd_config<br />
Port 22<br />
Port 443</code></p>
<p>This tells the OpenSSH daemon to listen on both ports 22 and 443. Of course, if you have an SSL enabled webserver running, this won't work for you, but if not, it works great.</p>
<p>After you restart your SSH daemon, you should be good to go.  Hopefully this helps you out in defeating your school or workplace's draconian ISA server.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.disflux.org/2011/03/ssh-through-an-isa-proxy-with-ntlm-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

