<?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>atppp&#039;s Blog &#187; encryption</title>
	<atom:link href="http://blog.wuxinan.net/archives/tag/encryption/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.wuxinan.net</link>
	<description></description>
	<lastBuildDate>Tue, 08 Dec 2009 08:20:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>rsyncrypto: rsync + encryption</title>
		<link>http://blog.wuxinan.net/archives/86</link>
		<comments>http://blog.wuxinan.net/archives/86#comments</comments>
		<pubDate>Fri, 07 Sep 2007 08:04:55 +0000</pubDate>
		<dc:creator>atppp</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lang:en]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://blog.wuxinan.net/?p=86</guid>
		<description><![CDATA[rsyncrypto is basically rsync plus encryption. It&#8217;s not feature-complete I guess, but it works for me. Ubuntu source has binary package but compiling isn&#8217;t hard at all. Alright, so obviously man page has most of what you need, here I&#8217;ll write simple outlines. Suppose your data source folder is ~/src, sync destination is ~/dst (this [...]]]></description>
			<content:encoded><![CDATA[<p>rsyncrypto is basically rsync plus encryption. It&#8217;s not feature-complete I guess, but it works for me. Ubuntu source has binary package but compiling isn&#8217;t hard at all. Alright, so obviously man page has most of what you need, here I&#8217;ll write simple outlines.</p>
<p>Suppose your data source folder is ~/src, sync destination is ~/dst (this could be a mounted nfs or smb share), and rsyncrypto working directory is ~/rr.</p>
<p><span style="text-decoration: underline;">A. Encryption</span></p>
<p>First of all, create backup keys:</p>
<pre>openssl req -nodes -newkey rsa:1536 -x509 \
  -keyout ~/rr/backup.key -out ~/rr/backup.crt</pre>
<p>Then the actual sync command is:</p>
<pre>rsyncrypto --ne-nesting=2 --trim=3 -n ~/rr/map \
  -cvr ~/src/ ~/dst/ ~/rr/keys ~/rr/backup.crt</pre>
<p>This command will encrypt filename and folder structure. So obviously folder modification time will not be preserved, and empty folder will be lost. Parameter <code>--trim</code> depends on your folder location. <code>--ne-nesting</code> depends on the number of files you will have in the future. In general, you may want less than 1024 files per folder, so you need 1024*16^n  &gt; total number of files, <code>--ne-nesting=2</code> is enough for 200,000 files. After this encrypted sync, and suppose you lose everything except files in the ~/dst/, then you&#8217;ll need backup.key to cold decrypt all files. So be sure to keep backup.key at another place, preferably at another physical location. You can put the above command into crontab if <code>-v</code> is removed. Also, syncing files without ownership might result in errors, and it may be hard to debug because rsyncrypto does not have very friendly error messages &#8211; in which case you may try to fix the file permission problem, or you may run the command by root.</p>
<p>If you want a parameter similar to <code>--delete</code> in rsync, the corresponding parameter in rsyncrypto is <code>--delete-keys</code>. The parameter <code>--delete</code> alone in rsyncrypto does not remove filename mapping in ~/rr/map.</p>
<p><span style="text-decoration: underline;">B. Decryption</span></p>
<p>Suppose you want to cold decrypt to folder ~/rec/. First you need to decrypt filename mapping:</p>
<pre>rsyncrypto -d ~/dst/filemap ~/rec/filemap \
  ~/rec/filemap-keys ~/rr/backup.key</pre>
<p>The above command generates ~/rec/filemap, so then you can decrypt all files:</p>
<pre>rsyncrypto --trim=3 -n ~/rec/filemap \
  -vrd ~/dst ~/rec/files ~/rec/keys ~/rr/backup.key</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.wuxinan.net/archives/86/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

