<?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>Piece of Unix Hints &#187; Unix</title>
	<atom:link href="http://hints.jeb.be/category/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://hints.jeb.be</link>
	<description>hints.jeb.be</description>
	<lastBuildDate>Fri, 04 Dec 2009 20:35:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Tiff to JPEG</title>
		<link>http://hints.jeb.be/2008/12/20/tiff-to-jpeg/</link>
		<comments>http://hints.jeb.be/2008/12/20/tiff-to-jpeg/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 16:08:02 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[Graphics]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=44</guid>
		<description><![CDATA[for file in `ls *.tiff`; do file2=`basename $file .tiff`;/bla/bin/tifftopnm "$file" &#124; /bla/bin/pnmtojpeg > "$file2.jpg"; done]]></description>
			<content:encoded><![CDATA[<pre>for file in `ls *.tiff`; do file2=`basename $file .tiff`;/bla/bin/tifftopnm "$file" | /bla/bin/pnmtojpeg > "$file2.jpg"; done</pre>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/20/tiff-to-jpeg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Per virtual user sa-learn training</title>
		<link>http://hints.jeb.be/2008/12/17/per-virtual-user-sa-learn-training/</link>
		<comments>http://hints.jeb.be/2008/12/17/per-virtual-user-sa-learn-training/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:53:14 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[SpamAssassin]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=42</guid>
		<description><![CDATA[Context I use a LDA that use Virtual User, and store email in /some/path/mail/&#60;domaine.tld&#62;/&#60;user&#62;/, this is a quite standard way to do. I also use spamassassin but wanted to have a per user bayes database and configuration. It&#8217;s still simple with spamc/spamd by running spamd -c --virtual-config-dir=/some/path/to/spamassassin/%d/%l ... and invoking spamc from you MTA with [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Context</strong></p>
<p>I use a LDA that use Virtual User, and store email in /some/path/mail/&lt;domaine.tld&gt;/&lt;user&gt;/, this is a quite standard way to do.<br />
I also use spamassassin but wanted to have a per user bayes database and configuration. It&#8217;s still simple with spamc/spamd by running <code>spamd -c --virtual-config-dir=/some/path/to/spamassassin/%d/%l ...</code> and invoking spamc from you MTA with <code>spamc -u ${recipient} -f -e /path/to/your/LDA</code> so that i have user preference in <code>/some/path/saconf/&lt;domaine.tld&gt;/&lt;user&gt;/</code>.<br />
Now I would like to provide 2 imap folder to users, LearnSpam and LearnHam so that they could train their bayes database.<br />
Here the problem start, especially if you are not using one of the latest spamassassin version.<br />
<strong></strong></p>
<p><strong>The bad way<br />
</strong><br />
What sa-learn command will you run to take care of LearnSpam and LearnHam folders ? sa-lean has an &#8211;username option, you may want to use that but this is not intended to be use in this case, it&#8217;s to be used when bayes database are stored in an SQL database instead of file (this is correctly documented in latest SA version). So don&#8217;t try <code>sa-learn --username=&lt;user&gt;@&lt;domaine.tld&gt; --spam /some/path/mail/&lt;domaine.tld&gt;/&lt;user&gt;/.INBOX.LearnSpam/cur/*</code> it will not work. Imagine how this can work ? it can&#8217;t, how sa-learn could convert &lt;user&gt;@&lt;domaine.tld&gt; to /some/path/saconf/&lt;domaine.tld&gt;/&lt;user&gt;/ ?</p>
<p><strong>The good way<br />
</strong><br />
So the right command to use is <code>sa-learn -p /some/path/saconf/&lt;domaine.tld&gt;/&lt;user&gt;/user_prefs --spam /some/path/mail/&lt;domaine.tld&gt;/&lt;user&gt;/.INBOX.LearnSpam/cur/*</code> Using the -D (debug) option could be very helpfull to check if it&#8217;s work correctly, you must see <code>dbg: bayes: tie-ing to DB file R/O /some/path/saconf/&lt;domaine.tld&gt;/&lt;user&gt;/bayes_toks</code></p>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/per-virtual-user-sa-learn-training/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Backup file of multiple user with rsync</title>
		<link>http://hints.jeb.be/2008/12/17/backup-file-of-multiple-user-with-rsync/</link>
		<comments>http://hints.jeb.be/2008/12/17/backup-file-of-multiple-user-with-rsync/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:52:07 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=40</guid>
		<description><![CDATA[root problem with rsync Imagine that you want to backup the /home directory of server &#8216;A&#8217; to server &#8216;B&#8217; using rsync. There is two way to do this : You can run rsync on the server &#8216;A&#8217;, but if you want to correctly backup (I mean, having correct uid/gid/.. on backuped files) files you should [...]]]></description>
			<content:encoded><![CDATA[<p><strong>root problem with rsync</strong></p>
<p>Imagine that you want to backup the /home directory of server &#8216;A&#8217; to server &#8216;B&#8217; using rsync.</p>
<p>There is two way to do this :</p>
<ul>
<li>You can run rsync on the server &#8216;A&#8217;, but if you want to correctly backup (I mean, having correct uid/gid/.. on backuped files) files you should connect to the server &#8216;B&#8217; as root. I&#8217;m sure you don&#8217;t want to do that.</li>
</ul>
<ul>
<li>You can run rsync on the server &#8216;B&#8217;, but you should connect to &#8216;A&#8217; with an user that can read all file in /home. This could be complicated depending of your gid managment.</li>
</ul>
<p><strong>When Tar start to be your best friend<br />
</strong><br />
So how can you do ? the solution would be to store (uid/gid/permission/..) information in a dedicated file, so that you can apply them if you need to restore data.<br />
How can you do that ? I&#8217;m sure you are too lazy to write a shell/perl/python/.. script to do that. You&#8217;re right ! Use tar.<br />
What ? What ? You want me to tar /home and rsync it ? Are you mad ? I don&#8217;t use rsync to transfer 20Go at each backup.</p>
<p><strong>When 1 option and 2 lines can save you<br />
</strong><br />
Tar as an incremental option. This mean that you can make a 1st tar file with /home then you can do a 2nd tar file with only modified file since previous tar. This option is -g.<br />
Here is a 2 lines shell script to do the job</p>
<pre>gtar -g /var/backup/home/home-backup.snar -cpvzf /var/backup/home/home-backup.`/bin/date +%s`.tgz /home/
rsync --delay-updates -avz -e ssh /var/backup/home backupuser@'B':/var/backup/</pre>
<p>&#8211;delay-updates is very important because if you don&#8217;t use it if &#8216;A&#8217; crash when rsync is copying the .snar file (used to store incrementation information) you will miss it on &#8216;B&#8217; and can&#8217;t retore tar file correctly.<br />
-g only exist in GNU Tar. You may have to install it if you&#8217;re running *BSD. First check if you have a gtar binnary</p>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/backup-file-of-multiple-user-with-rsync/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PPP Over SSH</title>
		<link>http://hints.jeb.be/2008/12/17/ppp-over-ssh/</link>
		<comments>http://hints.jeb.be/2008/12/17/ppp-over-ssh/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:47:40 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[PPP]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=32</guid>
		<description><![CDATA[You may want to establish a full IP connection to a remote host (or remote lan) but you may not have any VPN software on the remote host, or on your host. There is a solution using SSH and PPP with the command pppd pty 'ssh -x -t -e none user@server /usr/sbin/pppd passive noauth 9600' [...]]]></description>
			<content:encoded><![CDATA[<p>You may want to establish a full IP connection to a remote host (or remote lan) but you may not have any VPN software on the remote host, or on your host.<br />
There is a solution using SSH and PPP with the command</p>
<blockquote><p><code>pppd pty 'ssh -x -t -e none user@server /usr/sbin/pppd passive noauth 9600' noauth 10.0.0.1:10.0.0.2</code></p></blockquote>
<p>You have to use key authentication because the tty is redirected to pppd so you can&#8217;t be prompted for a password.<br />
With this command, you can reach server at IP 10.0.0.1.<br />
By playing with pppd and route tables you can extend the IP tunnel to the entire remote LAN.</p>
<p>This has been tested between Mac OS X and NetBSD but should work with any system.<br />
It works but it&#8217;s very slow.</p>
<p>On some system you may have TTY problem, if it&#8217;s your case take a look to <a  class="ext-link" href="http://www.ishiboo.com/~nirva/Projects/vpn/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.ishiboo.com/_nirva/Projects/vpn/?referer=');">http://shinythings.com/pty-redir/</a> or <a class="ext-link"  href="http://www.ishiboo.com/~nirva/Projects/vpn/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.ishiboo.com/_nirva/Projects/vpn/?referer=');">http://www.ishiboo.com/~nirva/Projects/vpn/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/ppp-over-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote Web Site Incremental Backup</title>
		<link>http://hints.jeb.be/2008/12/17/remote-web-site-incremental-backup/</link>
		<comments>http://hints.jeb.be/2008/12/17/remote-web-site-incremental-backup/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:41:32 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=22</guid>
		<description><![CDATA[Problem: You have a web site on a server but can&#8217;t connect to it with ssh but only FTP and you want to backup it daily but the website is huge, too huge to make a complete backup daily My solution is to put a php script on the webserver that list files with a [...]]]></description>
			<content:encoded><![CDATA[<p>Problem: You have a web site on a server but can&#8217;t connect to it with ssh but only FTP and you want to backup it daily but the website is huge, too huge to make a complete backup daily</p>
<p>My solution is to put a php script on the webserver that list files with a modification date in the last X seconds.<br />
Then within the following shell script I get the result of the php page then I retreive  listed file using FTP.</p>
<p>This is, I think, the most generic solution. I see an other one:</p>
<ul>
<li>It would be to create a tar archive in the php script, then download the .tar directly. This as 2 problems: It&#8217;s less secure unless you can apply an htaccess file on the .tar file to put an auth, you may not be allowed to execute binary on the remote server to do the tar.</li>
<li>You may also use <a class="ext-link" href="http://en.wikipedia.org/wiki/FTPFS" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/FTPFS?referer=');"><span class="icon">FTPFS</span></a>, it&#8217;s nice, but require that the host making the backup can use ftpfs <img src='http://hints.jeb.be/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p>This is the source of my SH script</p>
<div class="code">
<pre>#! /bin/sh

BK_YEAR="`date +%Y`"
BK_MONTH="`date +%b`"
BK_DAY="`date +%d`"

for file in `lynx -auth=login:password -source http://www.domain.com/admtool/last-modified.php`
do ADL="`echo $file | sed "s|/path/to/www.domain.com/root/document/or/the/ftp/chroot/path/||"`"
mkdir -p "/some/path/backup/domain.com/$BK_YEAR/$BK_MONTH/$BK_DAY/web-page/`dirname $ADL`"
wget -q --output-document="/some/path/backup/domain.com/$BK_YEAR/$BK_MONTH/$BK_DAY/web-page/$ADL" -r "ftp://login:pass@ftp.domain.com/$ADL"
done

tar -czf "/some/path/backup/domain.com/$BK_YEAR/$BK_MONTH/$BK_DAY/web-page.tgz" "/some/path/backup/domain.com/$BK_YEAR/$BK_MONTH/$BK_DAY/web-page"
rm -r "/some/path/wd1a/backup/domain.com/$BK_YEAR/$BK_MONTH/$BK_DAY/web-page"</pre>
</div>
<p>This is the source of my PHP script</p>
<div class="code">
<pre><span class="code-lang">&lt;?php 

$path </span><span class="code-keyword">= </span><span class="code-string">'.'</span><span class="code-keyword">;</span>
<span class="code-lang">$time </span><span class="code-keyword">= </span><span class="code-lang">86400</span><span class="code-keyword">;      </span><span class="code-comment">// will print all file modified in the last 86400 seconds</span>

<span class="code-lang">$curtime </span><span class="code-keyword">= </span><span class="code-lang">time</span><span class="code-keyword">();</span>

<span class="code-lang">GetFileList</span><span class="code-keyword">(</span><span class="code-lang">$path</span><span class="code-keyword">);

function </span><span class="code-lang">GetFileList</span><span class="code-keyword">(</span><span class="code-lang">$path</span><span class="code-keyword">) {</span>
<span class="code-lang">$curtime </span><span class="code-keyword">= </span><span class="code-lang">time</span><span class="code-keyword">();
        </span><span class="code-lang">$handle</span><span class="code-keyword">=</span><span class="code-lang">opendir</span><span class="code-keyword">(</span><span class="code-lang">$path</span><span class="code-keyword">);
                while(</span><span class="code-lang">$file </span><span class="code-keyword">= </span><span class="code-lang">readdir</span><span class="code-keyword">(</span><span class="code-lang">$handle</span><span class="code-keyword">)) {
                        if (</span><span class="code-lang">$file</span><span class="code-keyword">==</span><span class="code-string">'.' </span><span class="code-keyword">|| </span><span class="code-lang">$file</span><span class="code-keyword">==</span><span class="code-string">'..'</span><span class="code-keyword">) continue;
                        if (</span><span class="code-lang">is_dir</span><span class="code-keyword">(</span><span class="code-lang">$path </span><span class="code-keyword">. </span><span class="code-string">'/' </span><span class="code-keyword">. </span><span class="code-lang">$file</span><span class="code-keyword">)) {
                                </span><span class="code-lang">GetFileList</span><span class="code-keyword">(</span><span class="code-lang">$path </span><span class="code-keyword">. </span><span class="code-string">'/' </span><span class="code-keyword">. </span><span class="code-lang">$file</span><span class="code-keyword">);
                        }
                        else {
                                if ((</span><span class="code-lang">$curtime </span><span class="code-keyword">- </span><span class="code-lang">filemtime</span><span class="code-keyword">(</span><span class="code-lang">$path </span><span class="code-keyword">. </span><span class="code-string">'/' </span><span class="code-keyword">. </span><span class="code-lang">$file</span><span class="code-keyword">)) &lt; </span><span class="code-lang">86400</span><span class="code-keyword">) {
                                        echo </span><span class="code-lang">$path </span><span class="code-keyword">. </span><span class="code-string">'/' </span><span class="code-keyword">. </span><span class="code-lang">$file </span><span class="code-keyword">. </span><span class="code-string">"n"</span><span class="code-keyword">;
                                }
                        }
                }
        </span><span class="code-lang">closedir</span><span class="code-keyword">(</span><span class="code-lang">$handle</span><span class="code-keyword">);
}</span>

<span class="code-lang">?&gt;</span></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/remote-web-site-incremental-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How big is you MP3 collection all over your hard drives ?</title>
		<link>http://hints.jeb.be/2008/12/17/how-big-is-you-mp3-collection-all-over-your-hard-drives/</link>
		<comments>http://hints.jeb.be/2008/12/17/how-big-is-you-mp3-collection-all-over-your-hard-drives/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:40:01 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[MP3]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=19</guid>
		<description><![CDATA[You want to know the total size of all your .mp3 files ? (or any kind of file, juste change the locate argument) Try : locate .mp3 &#124; perl -e 'while(&#60;STDIN&#62;) { chop ; $tsize += -s $_; } print $tsize/1048576 . "Mo\n"' or locate .mp3 &#124; perl -e 'foreach (&#60;&#62;) { chop and $_["+"]+=-s$_ [...]]]></description>
			<content:encoded><![CDATA[<p>You want to know the total size of all your .mp3 files ? (or any kind of file, juste change the locate argument)</p>
<p>Try :</p>
<pre>locate .mp3 | perl -e 'while(&lt;STDIN&gt;) { chop ; $tsize += -s $_; } print $tsize/1048576 . "Mo\n"'</pre>
<p>or
<pre>
locate .mp3 | perl -e 'foreach (&lt;&gt;) { chop and $_["+"]+=-s$_ } print $_["+"]/1048576 . "Mo\n"'</pre>
<p>or if you didn&#8217;t have perl (sorry for you <img src='http://hints.jeb.be/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>
<pre>locate .mp3 | awk '{print "\"" $0 "\""}' | xargs ls -l | awk 'BEGIN{s=0}{s+=($5/1024/1024)}END{print s "Mo"}'</pre>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/how-big-is-you-mp3-collection-all-over-your-hard-drives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add IPF rule automatically from log files</title>
		<link>http://hints.jeb.be/2008/12/17/add-ipf-rule-automatically-from-log-files/</link>
		<comments>http://hints.jeb.be/2008/12/17/add-ipf-rule-automatically-from-log-files/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:30:14 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[NetBSD]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[IPF]]></category>
		<category><![CDATA[Log]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=16</guid>
		<description><![CDATA[Here is a very simple command to add a rule to your firewall (IPF in my example) when you match something in a log file (apache in this case) for item in `tail -n 150 access_log &#124; grep "c+dir" &#124; awk '{print $1}'` ; do echo "block in quick on ne0 proto ip from $item [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a very simple command to add a rule to your firewall (IPF in my example) when you match something in a log file (apache in this case)</p>
<div class="code">
<pre>for item in `tail -n 150 access_log | grep "c+dir" | awk '{print $1}'` ;
  do echo "block in quick on ne0 proto ip from $item to any" &gt;&gt; /etc/ipf.conf ;
done</pre>
</div>
<p>This read 150 last line of access_log using tail, use grep as matching operator, use awk to catch ip (note that you could do /c+dir/{print $1} in awk to don&#8217;t use grep) then add a blocking rule in /etc/ipf.conf</p>
<p>You may want to add a comment to the end of the blocking rule saying why it was blocked.</p>
<p>Don&#8217;t forget to reload the firewall, /sbin/ipf -Fa -f /etc/ipf.conf for ipf, from time to time with cron to active the rule.</p>
<p>You may reload the firewall each time with</p>
<div class="code">
<pre>for item in `tail -n 150 access_log | grep "c+dir" | awk '{print $1}'` ;
  do echo "block in quick on ne0 proto ip from $item to any" &gt;&gt; /etc/ipf.conf; /sbin/ipf -Fa -f /etc/ipf.conf ;
done</pre>
</div>
<p>This system has 2 problems:</p>
<ul>
<li>You must run tail from cron as -f can&#8217;t work with the for statement.</li>
<li>Rules are added at the end of ipf.conf, this is very useless if you have <tt>pass in quick proto ip any to any port 80</tt> before.</li>
</ul>
<p>So, here is a Perl script that will do a better job.</p>
<div class="code">
<pre>my $IPF_FILE="/etc/ipf.conf";
my $TMP_FILE="/tmp/ipf.new.rules";
my %h;
open (FILE,"tail -fn 1 /usr/local/apache/logs/access_log|") || die "can't open FILE: $!";
 while (&lt;FILE&gt;) {
  if ($_ =~ /^(.*)s-s-.*c+dir/) {
   if(exists($h{"$1"})) { $h{"$1"}++ }
   else {
    $h{"$1"} = 1;
    open(IPF, "&lt; $IPF_FILE") or die "can't open $IPF_FILE: $!";
    open(TMP, "&gt; $TMP_FILE") or die "can't open $TMP_FILE: $!";
    print TMP "block in log quick on ne0 from $1 to anyn" or die "can't write to $TMP_FILE: $!";
    while (&lt;IPF&gt;) { (print TMP $_) or die "can't write to $TMP_FILE: $!"; }
    close(IPF)                  or die "can't close $IPF_FILE: $!";
    close(TMP)                  or die "can't close $TMP_FILE: $!";
    rename("$TMP_FILE", "$IPF_FILE") or die "can't rename $TMP_FILE to $IPF_FILE: $!";
    system("ipf -Fa -f $IPF_FILE");
   }
  }
 }
close (FILE);
}</pre>
</div>
<p>Incrementation of $h{&#8220;$1&#8243;} is totally useless here but you may use it for something (like waiting more than one attemp of the IP before adding it to IPF). $h is used to don&#8217;t firewall two time the same IP.</p>
<p>You may think that $h is not usefull because as we have blocked the IP, we will not get any new request from it. Not really</p>
<ul>
<li>Tail is not working really in live, it check time to time for new line then print them, so between the first request of the IP and the reload of the firwall, you may have more than one request (don&#8217;t forget that reloading ipf take time also);</li>
<li>My IPF rule is very strict, you may only block port 80, so you can still get request on port 443, or things like that.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/add-ipf-rule-automatically-from-log-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup through SSH</title>
		<link>http://hints.jeb.be/2008/12/17/backup-through-ssh/</link>
		<comments>http://hints.jeb.be/2008/12/17/backup-through-ssh/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:25:29 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[TAR]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=12</guid>
		<description><![CDATA[Why using SSH to transfer data when you can use SCP/SFTP ? Because sometime SCP is disable in SSH configuration. So here is an easy way to transfert data with ssh. Run something like this ssh -C &#60;host&#62; "cd /path/to/folder/to/transfer; tar cvf - *" &#124; tar xfv -C will compress tranfer using gzip, I didn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Why using SSH to transfer data when you can use SCP/SFTP ?<br />
Because sometime SCP is disable in SSH configuration.
</p>
<p>
So here is an easy way to transfert data with ssh. Run something like this
</p>
<pre class="wiki">ssh -C &lt;host&gt; "cd /path/to/folder/to/transfer; tar cvf - *" | tar xfv
</pre>
<p>
-C will compress tranfer using gzip, I didn&#8217;t do any test to see if it&#8217;s better to use -C to compress on the SSH level or to use tar cvzf to compress the tar file. If you do please give me result ! <br />
&#8220;| tar xvf&#8221; will extract file in your current directory, of course, you may want to leave them in the .tar file.</p>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/backup-through-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Time Password authentication system</title>
		<link>http://hints.jeb.be/2008/12/17/one-time-password-authentication-system/</link>
		<comments>http://hints.jeb.be/2008/12/17/one-time-password-authentication-system/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:18:25 +0000</pubDate>
		<dc:creator>Jeb</dc:creator>
				<category><![CDATA[NetBSD]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[OTP]]></category>

		<guid isPermaLink="false">http://hints.jeb.be/?p=6</guid>
		<description><![CDATA[S/key is an one time password authentication (OTP) system that prevent you from sending password in clear. It&#8217;s especially useful with system like telnet. It&#8217;s quite easy to setup on NetBSD. To start, run # skeyinit -s &#60;user&#62; [Adding user] You need the 6 english words generated from the "skey" command. Enter sequence count from [...]]]></description>
			<content:encoded><![CDATA[<p>S/key is an one time password authentication (OTP) system that prevent you from sending password in clear.<br /> It&#8217;s especially useful with system like telnet.
</p>
<p>
It&#8217;s quite easy to setup on NetBSD. To start, run
</p>
<pre class="wiki"># skeyinit -s &lt;user&gt;
[Adding user]
You need the 6 english words generated from the "skey" command.
Enter sequence count from 1 to 10000: Enter anything you want
Enter new seed [default NetB14423]: Just press return or enter something else
otp-md4 &lt;sequence count&gt; &lt;seed&gt;
s/key access password: &lt;Follow instruction bellow&gt;
</pre>
<p>
To get the s/key access password, you have to run the following command but <strong>be careful to do not run it on the remote host through telnet</strong>, <span class="underline">run it locally</span> !
</p>
<pre class="wiki"># skey &lt;sequence count you entered for skeyinit&gt; &lt;seed you use in skeyinit&gt;
</pre>
<p>
This will ask you for a password (use a secure one) and give you 6 english word, use them to complete the &#8220;s/key access password:&#8221; question.
</p>
<p>
Your S/Key authentification is ready !
</p>
<hr />
<p>
Next time you do a telnet connexion to the host you will get this prompt
</p>
<pre class="wiki">login: &lt;put your username&gt;
Password [otp-md4 &lt;random number&gt; &lt;seed you use in skeyinit&gt;]:
</pre>
<p>
To know the 6 english word password to use, you have to run the following command (on you local computer for example)
</p>
<pre class="wiki"># skey &lt;random number&gt; &lt;seed you use in skeyinit&gt;
</pre>
<p>
In fact the random number will be incremented by one each time you log in. You can easily generate (in advance) all 6 english word password for number X to Z, with the following command (another time, run this locally) :
</p>
<pre class="wiki">skey -n (Z-X) Z &lt;seed you use in skeyinit&gt;
</pre>
<p>
Z-X is the number of password to generate. Z mean the last generated password is for random number Z
</p>
<p>
N.B: <strong>You clear password will still work if you use it.</strong>
</p>
<hr />
<p>
Related link: <a class="ext-link" href="http://en.wikipedia.org/wiki/S/Key" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/S/Key?referer=');"><span class="icon">S/Key on Wikipedia</span></a></p>
]]></content:encoded>
			<wfw:commentRss>http://hints.jeb.be/2008/12/17/one-time-password-authentication-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
