<?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>FLX &#187; How To&#8217;s</title>
	<atom:link href="http://flx.me/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://flx.me</link>
	<description>rambles, code and science!</description>
	<lastBuildDate>Tue, 09 Mar 2010 12:47:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>rTorrent notifications on your iPhone</title>
		<link>http://flx.me/rtorrent-notifications-on-your-iphone/</link>
		<comments>http://flx.me/rtorrent-notifications-on-your-iphone/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 15:20:22 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[How To's]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[Code Snippet of the Week]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[prowl]]></category>
		<category><![CDATA[rtorrent]]></category>

		<guid isPermaLink="false">http://flx.me/?p=276</guid>
		<description><![CDATA[As mentioned in my previous post I promised to explain how you can create Prowl push notifications using rTorrent and Prowl 4 Linux. It&#8217;s actually a variation of the rTorrent download log script that I talked about on in a earlier post. Instead of logging to a file, we are sending a prowl notification using [...]]]></description>
			<content:encoded><![CDATA[<p>As mentioned in my <a href="http://flx.me/prowl-4-linux">previous post</a> I promised to explain how you can create <a href="http://flx.me/prowl-4-linux">Prowl</a> push notifications using <a href="http://libtorrent.rakshasa.no/wiki">rTorrent</a> and <a href="http://flx.me/prowl-4-linux" target="_blank">Prowl 4 Linux</a>. It&#8217;s actually a variation of the rTorrent download log script that I talked about on in a <a href="http://flx.me/logging-downloads-with-rtorrent/">earlier post</a>. Instead of logging to a file, we are sending a prowl notification using the $d.get_name variable.<br />
<span id="more-276"></span><br />
I recommend you first read about <a href="http://flx.me/logging-downloads-with-rtorrent/">Logging downloads with rTorrent</a> and get <a href="../prowl-4-linux/">Prowl 4 Linux</a> working before continuing.</p>
<p>For logging downloads with rTorrent we used the following script:</p>
<p><span><code>#!/bin/bash</code><br />
<code>dldate=`date '+%A %d %B %H:%M%P'`</code><br />
<code>echo -ne "$2 completed on $dldate\r\n" &gt;&gt; /home/flx/downloaded.txt</code><br />
<code>exit 0</code></span></p>
<p>The line that did all the work was:</p>
<p><span><code>echo -ne "$2 completed on $dldate\r\n" &gt;&gt; /home/flx/downloaded.txt</code></span></p>
<p><span>As mentioned in the earlier post it takes the second argument (the name of the torrent) and writes that to a file. Instead of writing it to a file, we are going to execute prowl.sh and use the torrent name as the argument for the description:<br />
</span></p>
<p>/home/flx/prowl.sh -1 rTorrent &#8220;$2 completed on $dldate&#8221;</p>
<p>The command creates a low priority notification called &#8220;rTorrent&#8221; and sends the torrentname and date of completion as description. It should look like this:</p>
<p><span><code>Ubuntu_9.10RC.iso completed on Monday 26 October 12:53pm</code></span></p>
<p><span>That&#8217;s all! Here is how it looks on Prowl:</span></p>
<p><span><img class="alignleft size-full wp-image-205" title="prowl" src="http://flx.me/wp-content/uploads/2009/10/prowl.jpg" alt="prowl" width="320" height="480" /><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/rtorrent-notifications-on-your-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logging downloads with rTorrent</title>
		<link>http://flx.me/logging-downloads-with-rtorrent/</link>
		<comments>http://flx.me/logging-downloads-with-rtorrent/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 14:53:26 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[How To's]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[Code Snippet of the Week]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rtorrent]]></category>

		<guid isPermaLink="false">http://flx.me/?p=202</guid>
		<description><![CDATA[rTorrent has got to be one of the best torrent clients out there, especially for linux. It&#8217;s flexibility really shows when you get down to the nitty gritty in .rtorrent.rc.  I for example wrote a script that logs every download that has been completed to a text file, so that I can review all what [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://libtorrent.rakshasa.no/wiki" target="_blank">rTorrent</a> has got to be one of the best torrent clients out there, especially for linux. It&#8217;s flexibility really shows when you get down to the nitty gritty in .rtorrent.rc.  I for example wrote a script that logs every download that has been completed to a text file, so that I can review all what I&#8217;ve downloaded instead of trying to remember. I shall explain how I did this in this post.<br />
<span id="more-202"></span>I assume that you have prior knowledge of rTorrent and it&#8217;s workings. It&#8217;s not as easy as other bittorrent clients but it really pays off to learn this one.</p>
<p>It is possible to execute certain actions upon the completion of a torrent, this can be done with the action on_finished. It also allows you to take certain variables from the torrent that has finished and use it in commands. My on finished line looks like this:</p>
<p>system.method.set_key = event.download.finished,writer,&#8221;execute=/opt/flx/.rtorrent/writecomplete.sh,$d.get_directory_base=,$d.get_name=&#8221;</p>
<p>It executes a bash file (writecomplete.sh) with 2 arguments:</p>
<p><code>$d.get_directory_base (e.g /home/flx/downloads/apps/Ubuntu_9.10RC.iso)</code></p>
<p><code>$d.get_name </code><code>(Ubuntu_9.10RC.iso)</code></p>
<p>You can use these arguments to write them to a text file. My bash file (writecomplete.sh) looks like this:</p>
<p><code>#!/bin/bash</code><br />
<code>dldate=`date '+%A %d %B %H:%M%P'`</code><br />
<code>echo -ne "$2 completed on $dldate\r\n" &gt;&gt; /home/flx/downloaded.txt</code><br />
<code>exit 0</code></p>
<p>It takes the second argument (the torrent name) and outputs it to a text file with the date. The output looks like this:<br />
<code>Ubuntu_9.10RC.iso completed on Monday 26 October 12:53pm</code></p>
<p>I personally don&#8217;t like to log everything that I download. Lets say I only want to log downloads made to /home/flx/downloads/apps/ but not to any other folder, we can make this conditional by using:</p>
<p><code>#!/bin/bash</code><br />
<code>dldate=`date '+%A %d %B %H:%M%P'`</code><br />
<code>if [ `dirname $1` == "/home/flx/downloads/apps" ] ; then</code><br />
<code>echo -ne "$2 completed on $dldate\r\n" &gt;&gt; /home/flx/downloaded.txt</code><br />
<code>fi</code><br />
<code>exit 0</code></p>
<p>This script will only log downloads if torrents are downloaded to <code>/home/flx/downloads/apps<br />
</code><br />
Other directories will be ignored.</p>
<p>You can also deliver notifications to your iPhone using rTorrent completed trigger and Prowl4Linux, you can read more on that here:</p>
<p><a href="http://flx.me/rtorrent-notifications-on-your-iphone-with-prowl/">rTorrent notifications on your iPhone with Prowl</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/logging-downloads-with-rtorrent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Secure SSH Tunnel User</title>
		<link>http://flx.me/creating-a-secure-ssh-tunnel-user/</link>
		<comments>http://flx.me/creating-a-secure-ssh-tunnel-user/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 09:58:35 +0000</pubDate>
		<dc:creator>FLX</dc:creator>
				<category><![CDATA[How To's]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://flx.me/?p=66</guid>
		<description><![CDATA[It appears that I have the chronic problem of keeping sites interesting and ongoing due to not providing enough new content. So here I give you a sporadic new post. SSH Tunneling is great but it is often forgotten that the tunnel is running on a user with access rights to the server. To combat [...]]]></description>
			<content:encoded><![CDATA[<p>It appears that I have the chronic problem of keeping sites interesting and ongoing <a href="http://www.urbandictionary.com/define.php?term=unmotivated">due to not providing enough new content</a>. So here I give you a sporadic new post.</p>
<p><a href="http://en.wikipedia.org/wiki/Tunneling_protocol#SSH_tunneling">SSH Tunneling</a> is great but it is often forgotten that the tunnel is running on a user with access rights to the server.</p>
<p>To combat this you can create a specific user that can only tunnel over ssh whilst not allowing that user to browse directories, execute stuff, etc.</p>
<p><span id="more-66"></span></p>
<p>First of all you will need to create a user using <a href="http://www.annodex.net/cgi-bin/man/man2html?8+adduser">adduser</a> or <a href="http://www.annodex.net/cgi-bin/man/man2html?8+useradd">useradd</a> (depending how retarded your distro is) and securely jail it to a directory. Also make sure that you can log in to this user over ssh. I won&#8217;t go through these steps since they can be easily found on the web.</p>
<p>Next, add this to the end of the user profile:<br />
<code>./jail.sh<br />
exit 0<br />
</code><br />
The user profile can be found in its home directory under the name of .profile or .bash_profile. Again, this depends on your distro.</p>
<p>Next create a file called jail.sh in the home directory and use something like this:<code><br />
#!/bin/sh<br />
echo "SSH Tunnel user, press a key to exit."<br />
read x<br />
exit<br />
</code></p>
<p>Save the file and chmod it:<br />
<code>chmod +x jail.sh</code></p>
<p>If you now log in to the user via ssh it will keep the session open until a key is pressed. This will allow you to ssh tunnel over that specific account whilst denying any other actions that may harm you if someone gets a hold of that account.</p>
<p>For the actual tunneling itself I recommend using <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">PuTTY</a> or <a href="http://www.bitvise.com/tunnelier">Tunnelier</a> for Windows.<br />
For Linux, just use something along the lines of the following command:<br />
<code>ssh -fqND 8086 sshtunnelusr@my.ip.com -p 4423</code></p>
<p><em>8086</em> is the port of the local SOCKS proxy.<br />
<em>sshtunnelusr</em> is the remote ssh server user.<br />
<em>my.ip.com</em> is the remote ssh server IP.<br />
<em>4423</em> is the remote ssh server port, default is 22.</p>
<p>Questions? Ask them in the comment section or <a href="http://flx.me/contact/">contact me</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://flx.me/creating-a-secure-ssh-tunnel-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
