<?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>marius &#187; HowTo</title>
	<atom:link href="http://devilx.net/tag/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://devilx.net</link>
	<description></description>
	<lastBuildDate>Mon, 14 May 2012 21:25:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>A brief summary of setting up a CentOS 5.4 DRBD Cluster in Primary/Primary</title>
		<link>http://devilx.net/2009/11/14/a-brief-summary-of-setting-up-a-centos-5-4-drbd-cluster-in-primaryprimary/</link>
		<comments>http://devilx.net/2009/11/14/a-brief-summary-of-setting-up-a-centos-5-4-drbd-cluster-in-primaryprimary/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 20:10:45 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Linux and stuff ...]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[CMAN]]></category>
		<category><![CDATA[Coffee]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[DRBD]]></category>
		<category><![CDATA[GFS]]></category>
		<category><![CDATA[Grub]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[HPET]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OCFS]]></category>
		<category><![CDATA[OpenAIS]]></category>
		<category><![CDATA[RedHat]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[SELinux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Storage]]></category>
		<category><![CDATA[SuSE]]></category>
		<category><![CDATA[TSC]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[x86_64]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=1090</guid>
		<description><![CDATA[Clustering is cool and fun when it&#8217;s working, but for getting to such status it mostly takes like a dozen hours, coffee and many nerves. To simplify it a bit, I&#8217;d like to share some information on that topic, especially &#8230; <a href="http://devilx.net/2009/11/14/a-brief-summary-of-setting-up-a-centos-5-4-drbd-cluster-in-primaryprimary/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Clustering is cool and fun when it&#8217;s working, but for getting to such status it mostly takes like a dozen hours, coffee and many nerves. To simplify it a bit, I&#8217;d like to share some information on that topic, especially the stones I stumbled over.</p>
<p>First of all, we defined our scenario. Let&#8217;s assume that we&#8217;d like to have a cluster of two servers, both running the latest CentOS (5.4), both up-to-date, both using the very same partitioning and both using DRBD and GFS(2). On most SuSE or Debian systems, the installation would be pretty straight-forward: You install the base system, set up the DRBD, format it with some OCFS and make Heartbeat monitor everything. So far so good. On RHEL/CentOS it seems to work a bit different, due to the different tools they&#8217;re using. When installing the installation-group &#8220;Cluster Storage&#8221; for example, yum fetches packages named openais and cman &#8211; tools you&#8217;ve probably never heard of, when you come form the Debian corner (as I do). But before I describe those in detail, let&#8217;s just configure our plain base-installation.</p>
<p>What do we need to do first? What&#8217;s one of the most important things on two systems that should run &#8220;symmetrically&#8221; and have the very same data available, with every change that&#8217;s being made every second? Exactly, the time would be one of those things. We need to assure that both systems use the very same time. Mostly, you&#8217;ll be using some x86_64 hardware for such setups, where the problems start: On 64-bit hardware, the timekeeping with TSC doesn&#8217;t run <strong>that</strong> perfect, which is why we should just deactivate it and leave HPET do its job alone. After installing ntpd we need to open our grub.conf and add the notsc option to our kernels. It should looks something like this:</p>
<blockquote><p>===================================================================<br />
RCS file: /etc/grub.conf,v<br />
retrieving revision 1.1<br />
diff -u -r1.1 /etc/grub.conf<br />
&#8212; /etc/grub.conf	2009/11/13 13:30:26	1.1<br />
+++ /etc/grub.conf	2009/11/13 13:32:26<br />
@@ -13,9 +13,9 @@<br />
hiddenmenu<br />
title CentOS (2.6.18-164.6.1.el5)<br />
root (hd0,0)<br />
-	kernel /vmlinuz-2.6.18-164.6.1.el5 ro root=LABEL=/<br />
+	kernel /vmlinuz-2.6.18-164.6.1.el5 ro root=LABEL=/ notsc<br />
initrd /initrd-2.6.18-164.6.1.el5.img<br />
title CentOS (2.6.18-164.el5)<br />
root (hd0,0)<br />
-	kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/<br />
+	kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/ notsc<br />
initrd /initrd-2.6.18-164.el5.img</p></blockquote>
<p>Now, we can shutdown the ntpd and set its drift-file to 0.000. After that, simply reboot and check the dmesg for the HPET-lines and of course also check the time on both systems to be identically.</p>
<p>Now, what else should we configure until we start building our actual cluster? Probably, we should take a look into the system-config-securitylevel-tui tool. Depending on what environment you plan your cluster to run in, you either want to open each port by port manually in the firewall and configure your SELinux to allow CMAN/OpenAIS and DRBD to work properly &#8211; or you simply turn of those &#8220;toys&#8221; and configure the network-segment to be secure by itself. It depends to you and I&#8217;m not going to write how to reconfigure the firewall or your SELinux-environment. For my tests, I simply turned both off. Especially the combination of CMAN/OpenAIS and SELinux can become pretty tricky, when SELinux runs in any other mode than &#8220;Disabled&#8221;. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>Now, let&#8217;s finally please our inner kid and install some software:</p>
<blockquote><p># yum groupinstall &#8220;Cluster Storage&#8221;<br />
&#8230;<br />
# yum install drbd83 kmod-drbd83<br />
&#8230;</p></blockquote>
<p>I&#8217;ve chosen to use drbd83 since it&#8217;s the next stable release and already obsoletes drbd82 in CentOS 5.4 &#8211; and drbd is simply just too old. Of course, upgrades might become tricky when using explicitly versioned packages, but on DRBD it&#8217;s always a bit tricky, since there could be configuration changes which would have to be implemented manually on future versions.</p>
<p>However, now let&#8217;s create the infamous and poorly documented /etc/cluster/cluster.conf. For testing, we could simply use something like this:</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;cluster alias=&#8221;cluster-setup&#8221; config_version=&#8221;1&#8243; name=&#8221;cluster-setup&#8221;&gt;<br />
&lt;rm log_level=&#8221;4&#8243;/&gt;<br />
&lt;fence_daemon clean_start=&#8221;1&#8243; post_fail_delay=&#8221;0&#8243; post_join_delay=&#8221;3&#8243;/&gt;<br />
&lt;clusternodes&gt;<br />
&lt;clusternode name=&#8221;server-1.cross&#8221; nodeid=&#8221;1&#8243; votes=&#8221;1&#8243;&gt;<br />
&lt;fence&gt;<br />
&lt;method name=&#8221;2&#8243;&gt;<br />
&lt;device name=&#8221;LastResortNode01&#8243;/&gt;<br />
&lt;/method&gt;<br />
&lt;/fence&gt;<br />
&lt;/clusternode&gt;<br />
&lt;clusternode name=&#8221;server-2.cross&#8221; nodeid=&#8221;2&#8243; votes=&#8221;1&#8243;&gt;<br />
&lt;fence&gt;<br />
&lt;method name=&#8221;2&#8243;&gt;<br />
&lt;device name=&#8221;LastResortNode02&#8243;/&gt;<br />
&lt;/method&gt;<br />
&lt;/fence&gt;<br />
&lt;/clusternode&gt;<br />
&lt;/clusternodes&gt;<br />
&lt;cman expected_votes=&#8221;1&#8243; two_node=&#8221;1&#8243;/&gt;<br />
&lt;fencedevices&gt;<br />
&lt;fencedevice agent=&#8221;fence_manual&#8221; name=&#8221;LastResortNode01&#8243; nodename=&#8221;server-1.cross&#8221;/&gt;<br />
&lt;fencedevice agent=&#8221;fence_manual&#8221; name=&#8221;LastResortNode02&#8243; nodename=&#8221;server-2.cross&#8221;/&gt;<br />
&lt;/fencedevices&gt;<br />
&lt;rm/&gt;<br />
&lt;totem consensus=&#8221;4800&#8243; join=&#8221;60&#8243; token=&#8221;10000&#8243; token_retransmits_before_loss_const=&#8221;20&#8243;/&gt;<br />
&lt;/cluster&gt;</p></blockquote>
<p>Configuring OpenAIS this way isn&#8217;t actually the best way&#8230; it&#8217;s not even &#8220;good&#8221;. But for testing (and understanding how stuff works) it should be enough. Those rules expect manual intervention when one of the two server should become unavailable and needs to be brought back into the cluster.</p>
<p>The domain &#8220;.cross&#8221; is expected to be a hostname.domainname entry within the /etc/hosts of each server and defines the direct cross-cable-connection from one server to another. We need this connection to shrink down network latency and provide a way for OpenAIS and (in this example) also DRBD to directly communicate with each other. A better setup would be to set the heartbeat on top of a serial-line, since it would be most fault-tolerant.</p>
<p>Okay, next. What&#8217;s left? Exactly, the actual DRBD &#8211; so let&#8217;s set it up:</p>
<blockquote><p>global { usage-count yes; }<br />
common { syncer { rate 100M; } }<br />
resource the-disk {<br />
protocol C;<br />
startup {<br />
wfc-timeout 20;<br />
degr-wfc-timeout 10;<br />
# become-primary-on both; # Uncomment this only after tested!<br />
}<br />
net {<br />
cram-hmac-alg sha1;<br />
shared-secret &#8220;i4m501337&#8243;;<br />
allow-two-primaries;<br />
}<br />
on server-1 {<br />
device    /dev/drbd1;<br />
disk      /dev/sdb;<br />
address   10.100.0.1:7789;<br />
meta-disk  internal;<br />
}<br />
on server-2 {<br />
device    /dev/drbd1;<br />
disk      /dev/sdb;<br />
address   10.100.0.2:7789;<br />
meta-disk  internal;<br />
}<br />
disk {<br />
fencing resource-and-stonith;<br />
}<br />
handlers {<br />
#outdate-peer &#8220;/sbin/handler&#8221;;<br />
}<br />
}</p></blockquote>
<p>This configuration defines our two servers and tells DRBD to use /dev/sdb on both for the actual data. Our meta-disk will be internal and with address we defined &#8211; guess what? &#8211; the IP addresses of our two servers. Those are the .cross-domain addresses!</p>
<p>Next, we initialize our meta-disks (on both nodes), set our generation identifier, start the actual DRBD service and check the roles it currently runs in:</p>
<blockquote><p># drbdadm create-md the-disk<br />
&#8230;<br />
# drbdadm &#8212; 6::::1 set-gi the-disk<br />
&#8230;<br />
# service drbd start<br />
&#8230;<br />
# drbdadm role all<br />
Secondary/Secondary</p></blockquote>
<p>If all those steps succeed, we can try to promote both nodes to primary:</p>
<blockquote><p># drbdadm primary all<br />
# drbdadm role all<br />
Primary/Primary</p></blockquote>
<p>And if this now worked out properly, we can enable the automatic promotion from within our drbd.conf:</p>
<blockquote><p># rcsdiff -u /etc/drbd.conf<br />
===================================================================<br />
RCS file: /etc/drbd.conf,v<br />
retrieving revision 1.2<br />
diff -u -r1.2 /etc/drbd.conf<br />
&#8212; /etc/drbd.conf	2009/11/13 10:34:23	1.2<br />
+++ /etc/drbd.conf	2009/11/13 15:16:26<br />
@@ -9,7 +9,7 @@<br />
startup {<br />
wfc-timeout 20;<br />
degr-wfc-timeout 10;<br />
-                # become-primary-on both; # Uncomment this only after tested!<br />
+                become-primary-on both; # Uncomment this only after tested!<br />
}<br />
net {<br />
cram-hmac-alg sha1;</p></blockquote>
<p>Great. <em>So we&#8217;re set up now?</em> Nope. We&#8217;re not. Next, we need to change DRBDs boot order in order for it to work properly with the GFS auto-mounting on boot:</p>
<blockquote><p># rcsdiff -u /etc/init.d/drbd<br />
===================================================================<br />
RCS file: /etc/init.d/drbd,v<br />
retrieving revision 1.1<br />
diff -u -r1.1 /etc/init.d/drbd<br />
&#8212; /etc/init.d/drbd	2009/11/13 10:57:15	1.1<br />
+++ /etc/init.d/drbd	2009/11/13 10:58:15<br />
@@ -1,6 +1,6 @@<br />
#!/bin/bash<br />
#<br />
-# chkconfig: 345 70 08<br />
+# chkconfig: 345 22 75<br />
# description: Loads and unloads the drbd module<br />
#<br />
# Copright 2001-2008 LINBIT Information Technologies</p></blockquote>
<p>And let it run on boot:</p>
<blockquote><p># chkconfig &#8211;level 345 drbd on</p></blockquote>
<p>Great! <em>So, now we are set up, right?</em> Nope, wrong. We have a running DRBD setup now, but we still lack of a cluster-able file-system. GFS2 is a pretty good choice for such a task, so let&#8217;s try to format the DRBD-device on <strong>one of our nodes</strong> with it:</p>
<blockquote><p># mkfs.gfs2 -p lock_dlm -t cluster-setup:mycluster /dev/drbd1 -j 2</p></blockquote>
<p>Before we can try to mount the device, we need to have OpenAIS/CMAN running, in order to manage our GFS consistency. Let&#8217;s start the cman service therefor (on both nodes!):</p>
<blockquote><p># service cman start</p></blockquote>
<p>Starting cman and starting fenced could take several seconds, be patient. If you installed both servers identically and followed this documentation step by step everything should work out just fine. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>At last, we can now mount our DRBD device into some folder (on both nodes) and start playing around with our fresh setup:</p>
<blockquote><p># mount -t gfs2 /dev/drbd1 /mnt/somefolder</p></blockquote>
<p>I hope everything worked out for you and I also hoped that this brief summary helped you getting a bit easier into the actual setup of such a cluster setup. Feel free to ask any questions or provide feedback in any form.</p>
<p>Enjoy! <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2009/11/14/a-brief-summary-of-setting-up-a-centos-5-4-drbd-cluster-in-primaryprimary/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Amazon EC2: How to Setup an Instance and Bundle it</title>
		<link>http://devilx.net/2009/11/01/amazon-ec2-how-to-setup-an-instance-and-bundle-it/</link>
		<comments>http://devilx.net/2009/11/01/amazon-ec2-how-to-setup-an-instance-and-bundle-it/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 16:25:46 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Linux and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[AMI]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Bucket]]></category>
		<category><![CDATA[Bundle]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[EBS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[Elastic]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[Instance]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[S3]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=1033</guid>
		<description><![CDATA[I know, that there are several documentations concerning Amazon&#8217;s Elastic Cloud Computing, though I&#8217;d like to describe some very first steps for using their infrastructure to build (Linux-) instances that fulfill your needs. Let&#8217;s not beat around the bush and &#8230; <a href="http://devilx.net/2009/11/01/amazon-ec2-how-to-setup-an-instance-and-bundle-it/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I know, that there are several documentations concerning Amazon&#8217;s Elastic Cloud Computing, though I&#8217;d like to describe some very first steps for using their infrastructure to build (Linux-) instances that fulfill your needs. Let&#8217;s not beat around the bush and start-over by setting up the very first instance.</p>
<p>The first thing needed is a client computer running any kind of the supported OSs by the Amazon API tools and of course the tools themselves. After you&#8217;ve installed those and configured all credentials the right way, we can create a new pair of SSH keys for our new project. Due to the location I&#8217;m currently in, I&#8217;ve chosen to use Amazon Instances in the western EU. Execute the following line on your command-line:</p>
<blockquote><p>ec2-add-keypair &#8211;region eu-west-1 test-keypair</p></blockquote>
<p>The result should look something like this:</p>
<blockquote><p>[Deprecated] Xalan: org.apache.xml.res.XMLErrorResources_en_US<br />
KEYPAIR	test-keypair	e1:1a:d1:a1:a1:1c:10:a1:b1:d1:cb:11:11:1a:11:11:f1:11:ae:fe<br />
&#8212;&#8211;BEGIN RSA PRIVATE KEY&#8212;&#8211;<br />
XXX<br />
&#8212;&#8211;END RSA PRIVATE KEY&#8212;&#8211;</p></blockquote>
<p>You can now copy the lines from <i>BEGIN&#8230;</i> until <i>END&#8230;</i> (including those two) into a file which you&#8217;ll be using as SSH-key for connecting to your instance. Don&#8217;t forget to <i>chmod 600</i> it!</p>
<p>Next, let&#8217;s see what base-images for creating our instance we could you &#8211; first, provided by Amazon themselves:</p>
<blockquote><p>
ec2-describe-images &#8211;region eu-west-1 -o &#8216;amazon&#8217;
</p></blockquote>
<p>The list is contained of several different OSs and versions, although in our current project we can&#8217;t make use of any of those. Therefor, we&#8217;re now searching for a perfectly fitting, really good operating system:</p>
<blockquote><p>
ec2-describe-images &#8211;region eu-west-1 -a | grep -i debian
</p></blockquote>
<p>And yet, we receive another list with several different versions of the Debian Linux distribution. After we&#8217;ve picked the one we&#8217;d like to run, we should check what instances are currently up and running:</p>
<blockquote><p>
ec2-describe-instances &#8211;region eu-west-1
</p></blockquote>
<p>If you&#8217;re using Amazon&#8217;s EC2 for the first time, there shouldn&#8217;t be any items listed. We can now start our very first instance, by copying the instance&#8217;s identifier (in the second column, a string starting with ami-<id>) and pasting it into our command:</p>
<blockquote><p>
ec2-run-instances &#8211;region eu-west-1 -k test-keypair -g &#8216;http/s&#8217; -g &#8216;ssh&#8217; ami-b8446fcc
</p></blockquote>
<p>In this command, we tell Amazon to start up a new instance that&#8217;s built on top of the ami-b8446fcc-image, using the key-pair we just created before and using some custom built firewall-rules named &#8220;http/s&#8221; (which allows us to connect to port 80 and 443) and &#8220;ssh&#8221; (port 22).</p>
<p>We need to wait a few seconds, until the instance comes up. We can use the describe-instances command from above to check the instance&#8217;s status:</p>
<blockquote><p>
ec2-describe-instances &#8211;region eu-west-1
</p></blockquote>
<p>As soon as it&#8217;s up and running, the &#8220;pending&#8221; column should have been replaced by a dynamically allocated hostname and the status &#8220;running&#8221;. Keep in mind, that this hostname/ip is dynamically allocated! If you want a fixed IP, you need to allocate and assign an Elastic IP &#8211; I&#8217;ll show you later how to do so.<br />
If our firewall rules worked out, we can now connect using SSH:</p>
<blockquote><p>
ssh -i ~/Library/EC2/id_rsa-test-keypair root@ec2-11-111-11-111.eu-west-1.compute.amazonaws.com
</p></blockquote>
<p>By default, Amazon sets up a Small Instance, that provides around 10 GB of hard drive, an Dual-Core AMD Opteron 2218 with 2600 MHz and around 1.7 GB of RAM. Small instances, in comparison to the bigger ones, also still provide a real swap-partition which is limited to 895 MB. Here, you could run into problems when installing some Oracle for example, since the DB would like to have 1 GB or more Swap-space. If 895 MB should not be enough, the only way to enlarge it seems to be to use a file within your file-system for that. Either, by placing it somewhere into / or by using /mnt for that. /mnt is a special mount in Amazon instances which provides you 147 GB of additional <i>volatile</i> storage. Amazon doesn&#8217;t guarantee in any way the storage to be stable/solid or even backed up &#8211; and usually /mnt is only used for bundling your instance. You might now think <i>&#8220;so, where could I place my data, if / is only providing me 10 GB of space and /mnt should not be used for storing sensitive data?&#8221;</i> &#8211; well, there&#8217;s a third possibility named Elastic Block Storage. An EBS is being displayed to your instance as regular block-device (/dev/sdb, &#8230;) that&#8217;s format- and mountable. There, sensitive data could be stored, by bind-mounting the directories you&#8217;d like to have your data in. I&#8217;m not going to explain how this works, else I&#8217;ll never finish writing this brief documentation.</p>
<p>However, since we&#8217;re connected to the instance now, we can set it up the way we want it, with whatever software we need on it. I&#8217;ve assumed, that most people would set it up as regular LAMP-instance, therefor I&#8217;ve also added the firewall-rule for HTTP/HTTPS. After we finished installing the software we need, there&#8217;s one more package that should be plugged into the system: The Amazon AMI Tools. Simply wget them from http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip and unzip the package. Those tools make use of Ruby, so ensure having it installed on your instance. Also, you need to have the private key (pk-<id>.pem) and the certificate (cert-<id>.pem) you created the instance with somewhere within your instance&#8217;s filesystem, for later use.</p>
<p>Before we bundle up our system now, let&#8217;s come back to the topic we had before: The hostname/IP. Amazon allocates some dynamic address, unless you tell them to give you a fixed (called Elastic) IP. You can do that by simply executing:</p>
<blockquote><p>
ec2-allocate-address &#8211;region eu-west-1
</p></blockquote>
<p>&#8230; within your client&#8217;s command-line (where the Amazon API Tools have been installed &#8211; not on the instance!). As result you&#8217;ll get some IP address that has now being allocated by Amazon for you. The IP isn&#8217;t bound to any instance yet &#8211; it&#8217;s just allocated for you to be able to use it. ATTENTION: You pay for Elastic IPs as long as you do not assign them to an instance. Yes, that&#8217;s right. Amazon charges you for every allocated but unused IP hourly. By that, they want to prevent people &#8220;collecting&#8221; addresses, I guess. To assign the address you just received to your instance, simply run:</p>
<blockquote><p>
ec2-associate-address &#8211;region eu-west-1 -i i-11e11b1e 79.125.11.11
</p></blockquote>
<p>The i-<id> is your actual instance&#8217;s ID, where the last, dot-separated number is the IP you&#8217;ve received. And yes, those are fake numbers &#8211; so don&#8217;t even try. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/wink.png' alt=';]' class='wp-smiley' /> </p>
<p>Now it could take a bit for Amazon to reconfigure the instance, but as soon as it finished, you should be able to re-connect to the instance using the IP you just assigned to it.</p>
<p>As last task for today, let&#8217;s bundle up the image the way we have it now. Bundling an image allows you more than just eating up your credit card&#8217;s limit by dumping your S3 buckets. On the one hand, with bundles you can recover machines that crashed or lost data within a few blinks and on the other, you can created new instances out of a bundle (talking about &#8220;scalability&#8221;).</p>
<p>For bundling, we use the AMI tools we installed. First of all, let&#8217;s create a directory for the bundle:</p>
<blockquote><p>
mkdir /mnt/myimage
</p></blockquote>
<p>After that, run the bundle-vol-tool:</p>
<blockquote><p>
ec2-bundle-vol -k pk-<id>.pem -c cert-<id>.pem -s <bundle size in MB, e.g. 5000> -u <user-id, without dashes> -d /mnt/myimage/
</p></blockquote>
<p>This command takes several parameters for the private key, the certificate, the size of the resulting bundle in MB and your User-ID (without dashes). The User-ID can be found within your Account Information on Amazon&#8217;s EC2 site. The command should ask you, what architecture you&#8217;d like to bundle the system for &#8211; i386 should work out perfectly for what we&#8217;re doing. The following procedure could take some time, since the tool collections every peace of the system and builds a bundle into the directory we specified. As soon as the tool finished, we can upload our bundle to our S3-bucket:</p>
<blockquote><p>
ec2-upload-bundle &#8211;location EU -b <some unique bucket name>  -m /mnt/myimage/image.manifest.xml -a <access-key> -s <secret-key>
</p></blockquote>
<p>Again, we need to specify some credentials (our access-key and the secret-key) for the upload to work. Also, we need to pick a globally unique bucket-name for uploading the bundle, what shouldn&#8217;t be that hard as long as you don&#8217;t try stuff like &#8220;linux&#8221; or other common words. The bundle will then be uploaded to your (private) bucket, so you have it for later use.</p>
<p>From within the web-interface you could now simply create new instances out of the uploaded bundle, without even knowing how the actual system was set up or having the Amazon API tools installed on your client.</p>
<p>Cool stuff, enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2009/11/01/amazon-ec2-how-to-setup-an-instance-and-bundle-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Neil, this Tricky Little B&#8230;oy!</title>
		<link>http://devilx.net/2009/05/09/neil-this-tricky-little-boy/</link>
		<comments>http://devilx.net/2009/05/09/neil-this-tricky-little-boy/#comments</comments>
		<pubDate>Sat, 09 May 2009 16:20:20 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Hot Gear]]></category>
		<category><![CDATA[Life itself]]></category>
		<category><![CDATA[Mac and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Deskstar]]></category>
		<category><![CDATA[Do-It-Yourself]]></category>
		<category><![CDATA[Hard Drive]]></category>
		<category><![CDATA[Hitachi]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[LaCie]]></category>
		<category><![CDATA[Neil Poulton]]></category>
		<category><![CDATA[Open]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=872</guid>
		<description><![CDATA[For some time now I was searching for documentation on the internet about how to open my LaCie &#8220;Neil Poulton Design&#8221; hard drive, but I could not find anything. As it seems, this drive will be bought only by Apple &#8230; <a href="http://devilx.net/2009/05/09/neil-this-tricky-little-boy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For some time now I was searching for documentation on the internet about how to open my LaCie &#8220;Neil Poulton Design&#8221; hard drive, but I could not find anything. As it seems, this drive will be bought only by Apple users with probably two left hands and too much money for constantly spending it on a new one, when TimeMachine strewn it with its backups. Today then I thought, <em>&#8220;Eh, come on, I finally want to have this thing open!&#8221;</em> &#8211; and so I did.</p>
<p>First of all, let&#8217;s have a look at the drive itself. It&#8217;s plain. Really plain. No holes, no screws, nothing. How the f*ck shall we open this thing. Let&#8217;s take a look under its gum-feet. Nah, not even there. What he hack? So, as it seems, this drive can&#8217;t be opened. Wrong! <em>Yes we can</em>!</p>
<p>What do we need therefor?</p>
<table border="0">
<tbody>
<tr >
<td style="background-color: transparent;">
<p><div id="attachment_873" class="wp-caption alignnone" style="width: 160px"><a href="http://www.devilx.net/wp-content/uploads/2009/05/image005.jpg"><img class="size-thumbnail wp-image-873" title="A cloth, for not scratching the gloss" src="http://www.devilx.net/wp-content/uploads/2009/05/image005-150x150.jpg" alt="A cloth, for not scratching the gloss" width="150" height="150" /></a><p class="wp-caption-text">A cloth, for not scratching the gloss</p></div></td>
<td style="background-color: transparent;">
<p><div id="attachment_874" class="wp-caption alignnone" style="width: 160px"><a href="http://www.devilx.net/wp-content/uploads/2009/05/image006.jpg"><img class="size-thumbnail wp-image-874 " title="A strong thread" src="http://www.devilx.net/wp-content/uploads/2009/05/image006-150x150.jpg" alt="A strong thread" width="150" height="150" /></a><p class="wp-caption-text">A strong thread</p></div></td>
<td style="background-color: transparent;">
<p><div id="attachment_875" class="wp-caption alignnone" style="width: 160px"><a href="http://www.devilx.net/wp-content/uploads/2009/05/image007.jpg"><img class="size-thumbnail wp-image-875" title="A modified paperclip" src="http://www.devilx.net/wp-content/uploads/2009/05/image007-150x150.jpg" alt="A modified paperclip" width="150" height="150" /></a><p class="wp-caption-text">A modified paperclip</p></div></td>
</tr>
</tbody>
</table>
<p>Okay, now we&#8217;re all set up. First of all, take the hard drive and turn it upside-down. Place it on the cloth to not scratch its lickable, glossy exterior.</p>
<div id="attachment_876" class="wp-caption alignleft" style="width: 160px"><a href="http://www.devilx.net/wp-content/uploads/2009/05/image000.jpg"><img class="size-thumbnail wp-image-876" title="Place it on the cloth" src="http://www.devilx.net/wp-content/uploads/2009/05/image000-150x150.jpg" alt="Place it on the cloth" width="150" height="150" /></a><p class="wp-caption-text">Place it on the cloth</p></div>
<p>Next, take the thread and try to run it through the holes on the case&#8217;s bottom, so that you have something to pull the hard disk out of the case. Now try to bend the sides of the plastic-case out carefully and pull drive out piece for piece. You could also use some credit card or other thin piece of plastic (not metal, it will kill the plastic-borders!) for doing this. Warning, this could cause serious damage to your credit card!</p>
<p>Do the credit card-thing on the front-side, the left- and right-side. When pulled it out some millimeters on each of those side, take all the pieces of your thread and try to pull out the drive to the back (e.g. rotation of 90 degrees around the drive&#8217;s back-side). On the back, there&#8217;s the button for turning it on and off, so you won&#8217;t be able to pull it out vertically. If you&#8217;ve successfully managed to pull out the drive, the whole scenario should look similar to this:</p>
<table border="0">
<tbody>
<tr>
<td style="background-color: transparent;">
<p><div id="attachment_878" class="wp-caption alignnone" style="width: 160px"><a href="http://www.devilx.net/wp-content/uploads/2009/05/image002.jpg"><img class="size-thumbnail wp-image-878" title="Pulled out the drive" src="http://www.devilx.net/wp-content/uploads/2009/05/image002-150x150.jpg" alt="Pulled out the drive" width="150" height="150" /></a><p class="wp-caption-text">Pulled out the drive</p></div></td>
<td style="background-color: transparent;">
<p><div id="attachment_877" class="wp-caption alignnone" style="width: 160px"><a href="http://www.devilx.net/wp-content/uploads/2009/05/image001.jpg"><img class="size-thumbnail wp-image-877" title="Pulled out the drive" src="http://www.devilx.net/wp-content/uploads/2009/05/image001-150x150.jpg" alt="Pulled out the drive" width="150" height="150" /></a><p class="wp-caption-text">Pulled out the drive</p></div></td>
</tr>
</tbody>
</table>
<p>Now, you can see the actual hard drive which is mounted to the bottom-part of the whole case. After inspecting the construction you can see that there were to glueing-points or any hooks we broke while opening the drive. This means, that if you&#8217;ve done it right, you won&#8217;t see that anything ever changed on that drive.</p>
<p>Now, I can finally get myself a 750GB (or even 1TB?) hard-drive and build that in. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>Happy trying!</p>
<p>//btw: As you notice, LaCie builds in Hitachi Deskstars on these drives. These drives cost something around 50 bucks nowadays. The complete case is around 90 bucks.</p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2009/05/09/neil-this-tricky-little-boy/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>strongS/WAN over NAT-T with IKEv2 (Pt. 2, a.k.a. &#8220;The Roadwarrior Setup&#8221;)</title>
		<link>http://devilx.net/2008/10/08/strongswan-over-nat-t-with-ikev2-pt-2-aka-the-roadwarrior-setup/</link>
		<comments>http://devilx.net/2008/10/08/strongswan-over-nat-t-with-ikev2-pt-2-aka-the-roadwarrior-setup/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 12:41:54 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Linux and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[BSD]]></category>
		<category><![CDATA[Cool]]></category>
		<category><![CDATA[DHCP]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[IKE]]></category>
		<category><![CDATA[IKEv2]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[IPsec]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[NAT]]></category>
		<category><![CDATA[NAT-T]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[strongS/WAN]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=565</guid>
		<description><![CDATA[Some days ago I showed up a specific scenario and described how a strongS/WAN configuration for this could look like. Now, I would like to add additional information on how the scenario can be tuned so that even &#8220;Roadwarriors&#8221; could &#8230; <a href="http://devilx.net/2008/10/08/strongswan-over-nat-t-with-ikev2-pt-2-aka-the-roadwarrior-setup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some days ago I <a title="strongS/WAN over NAT-T with IKEv2" href="http://devilx.net/?p=558" target="_self">showed up a specific scenario and described</a> how a strongS/WAN configuration for this could look like. Now, I would like to add additional information on how the scenario can be tuned so that even &#8220;Roadwarriors&#8221; could connect from any network infrastructure, indifferent whether they&#8217;re directly on a public IP or share their public IP with others, behind another NAT network. Let&#8217;s take a look at the client config:<br />
<code><span id="more-565"></span><br />
config setup<br />
plutostart=no</code></p>
<p><code> </code></p>
<p><code>conn nat-t<br />
ikelifetime=60m<br />
keylife=20m<br />
rekeymargin=3m<br />
keyingtries=1<br />
keyexchange=ikev2<br />
authby=secret<br />
left=192.168.10.193<br />
leftsubnet=10.1.0.0/24<br />
leftfirewall=yes<br />
right=%defaultroute<br />
rightid=client@example.com<br />
rightsourceip=10.100.0.2<br />
auto=add<br />
</code><br />
We added a new virtual IP (rightsourceip) for the client. The network of this IP will be defined on the server&#8217;s configuration. We need this for the whole scenario to work out, even if the client/Roadwarrior is behind a NAT. As rightid (client-id) we use the client&#8217;s e-mail address.<br />
Server config:<br />
<code><br />
config setup<br />
plutostart=no</code></p>
<p><code> </code></p>
<p><code>conn nat-t<br />
ikelifetime=60m<br />
keylife=20m<br />
rekeymargin=3m<br />
keyingtries=1<br />
keyexchange=ikev2<br />
authby=secret<br />
left=10.1.0.4<br />
leftsubnet=10.1.0.0/24<br />
leftid=192.168.10.193<br />
leftfirewall=yes<br />
right=%any<br />
rightid=client@example.com<br />
rightsubnetwithin=10.100.0.0/24<br />
auto=add<br />
</code></p>
<p>Here, we also defined the client&#8217;s e-mail address as rightid, defined that the right side could be anything (&#8220;%any&#8221;) and told the server to serve the virtual network 10.100.0.0/24 for the right side. By that, the configuration can be applied to different clients and the actual IP configuration is provided on the client&#8217;s side. Yet, I did not find out whether there&#8217;s a possibility to set up some DHCP server and provide connecting clients a dynamic address automatically.<br />
However, this setup now also works with Roadwarriors that are behind NATs, what means that the actual setup could look like this:</p>
<p>[roadwarrior]&#8212;-[nat]&#8212;internet&#8212;[nat]&#8212;[server]&#8212;network</p>
<p>Isn&#8217;t this cool? <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/wink.png' alt=';-)' class='wp-smiley' /> <br />
Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2008/10/08/strongswan-over-nat-t-with-ikev2-pt-2-aka-the-roadwarrior-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>strongS/WAN over NAT-T with IKEv2</title>
		<link>http://devilx.net/2008/10/01/strongswan-over-nat-t-with-ikev2/</link>
		<comments>http://devilx.net/2008/10/01/strongswan-over-nat-t-with-ikev2/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 18:11:03 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Linux and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Cool]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[IKE]]></category>
		<category><![CDATA[IKEv2]]></category>
		<category><![CDATA[IPsec]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[NAT]]></category>
		<category><![CDATA[NAT-T]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[strongS/WAN]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=558</guid>
		<description><![CDATA[Yay, it&#8217;s time for another HowTo boys and girls! Okay, let&#8217;s cut that crap. So, imagine the following scenario: We&#8217;re in a network (in my example 192.168.10.0/24) and there are two components we focus on: One client (a Linux laptop, &#8230; <a href="http://devilx.net/2008/10/01/strongswan-over-nat-t-with-ikev2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yay, it&#8217;s time for another HowTo boys and girls! Okay, let&#8217;s cut that crap. So, imagine the following scenario:</p>
<p>We&#8217;re in a network (in my example 192.168.10.0/24) and there are two components we focus on: One client (a Linux laptop, 192.168.10.184) and a VMware Server (192.168.10.193). On this server, we have a VMware NAT-Network (10.1.0.0/24), where the gateway is has the 10.1.0.2 and our JumpHost has the 10.1.0.4. The client (our laptop) now wants to be able to simply connect other hosts within our 10.1.0.0/24 network. Besides, it would be nice to have some kind of security in bewteen these connections. So what would be better than using a VPN? <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>Of course, we could use simple SSH tunnels or some OpenVPN setup &#8211; but this would be boring. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/wink.png' alt=';-)' class='wp-smiley' /> So, we decide to to use IPsec. In detail, we&#8217;re using strongS/WAN to setup the whole scenario.</p>
<p>Now first of all we have two problems: First of all, we have a NAT (from the view of IPsec/IKE: NAT-Traversal) through which we can&#8217;t tunnel layer 3 protocols. The only thing we can do, is to teach our VMware Server to forward UDP or TCP ports to Guests.</p>
<p>The second thing that might become a problem is the fact, that we&#8217;re not using the IPsec daemon within the VM to distribute another network &#8211; instead we are distributing his own network. But however, enough with the talk, let&#8217;s do the work.</p>
<p>Thanks to <a title="SA_2006_NAT-T.pdf" href="http://security.hsr.ch/projects/SA_2006_NAT-T.pdf" target="_self">Tobias Brunner and Daniel RÃ¶thlisberger</a>, strongS/WAN experienced in 2006 the implementation of the NAT-T feature. This feature, allows to &#8220;tunnel&#8221; IPsec (a layer 3 protocol) through layer 4 (UDP). So the first thing we need to do, is to tell our VMware Server to forward the UDP ports 500 and 4500 to our JumpHost-VM. After we&#8217;ve done this, we can start setting up the strongS/WANs on the client and the JumpHost himself.</p>
<p><span id="more-558"></span>In this scenario I used Debian SID on both systems, since Debian&#8217;s current stable release provides only an very old version of strongS/WAN. So:<br />
<code><br />
aptitude install strongswan<br />
</code><br />
&#8230; on both systems. After that, we open the /etc/ipsec.secrets on both hosts and insert the following line:<br />
<code><br />
%any : PSK "abcdefghijklmnopqer"<br />
</code><br />
Of course, you can replace the key by your own one. After that, we take the ipsec.conf of the client and insert our configuration:<br />
<code><br />
config setup<br />
plutostart=no</code></p>
<p>conn nat-t<br />
ikelifetime=60m<br />
keylife=20m<br />
rekeymargin=3m<br />
keyingtries=1<br />
keyexchange=ikev2<br />
authby=secret<br />
left=192.168.10.193<br />
leftsubnet=10.1.0.0/24<br />
leftfirewall=yes<br />
right=192.168.10.184<br />
rightsubnet=192.168.10.0/24<br />
auto=add</p>
<p>As mentioned in the title, we use IKEv2. To simplify the scenario, we use the secret we just configured as authentication method. The configuration should be adaptable pretty easy for certificate usage.<br />
On the server we now also insert our configuration into the ipsec.conf:<br />
<code><br />
config setup<br />
plutostart=no</code></p>
<p>conn nat-t<br />
ikelifetime=60m<br />
keylife=20m<br />
rekeymargin=3m<br />
keyingtries=1<br />
keyexchange=ikev2<br />
authby=secret<br />
left=10.1.0.4<br />
leftsubnet=10.1.0.0/24<br />
leftid=192.168.10.193<br />
leftfirewall=yes<br />
right=%any<br />
auto=add</p>
<p>After restarting both daemons, executing <em>ipsec up nat-t</em> and also <em>ipsec route nat-t</em> you should be able to ping the hosts on our 10.1.0.0/24 network.</p>
<p>The tricky part in this setup is the leftid= parameter in out server&#8217;s configuration. Without that option the whole authentication procedure doesn&#8217;t work out, because the daemon will complain to not have any configuration for &#8220;[192.168.10.184]&#8230;[192.168.10.193]&#8221; and because of that not let the client connect. The reason for this is, that the client only sees the NAT-Router (our VMware Server, .193) and of course tries to sets up the connection using his IP. The NAT-Router then forwards the requests to the actual strongS/WAN daemon (10.1.0.4) which of course says <em>&#8220;Wtf?! I&#8217;m the 10.1.0.4, what should I do with this package I received for 192.168.10.193?&#8221;</em>. And this where the leftid= parameter comes in.</p>
<p>However, I think the stuff should be more clear now. If there are any questions left, feel free to ask. Enjoy! <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>Anyway, so that&#8217;s actually the whole setup.</p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2008/10/01/strongswan-over-nat-t-with-ikev2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebDAV over SSL using LDAP with Apache2 on Debian</title>
		<link>http://devilx.net/2008/09/07/webdav-over-ssl-using-ldap-with-apache2-on-debian/</link>
		<comments>http://devilx.net/2008/09/07/webdav-over-ssl-using-ldap-with-apache2-on-debian/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 16:36:16 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Linux and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Cool]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[PAM]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WebDAV]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=523</guid>
		<description><![CDATA[Some time ago, I just published a short summary of how to set up a WebDAV over SSL using Apache2 with PAM authentication. Unfortunatelly, the solution had one ugly part: The user www-data must be added to the group shadow, &#8230; <a href="http://devilx.net/2008/09/07/webdav-over-ssl-using-ldap-with-apache2-on-debian/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some time ago, <a title="WebDAV over SSL using PAM with Apache2 on Debian" href="http://devilx.net/?p=513" target="_self">I just published a short summary</a> of how to set up a WebDAV over SSL using Apache2 with PAM authentication. Unfortunatelly, the solution had one ugly part: The user www-data must be added to the group shadow, so that it can read the /etc/shadow which is needed for authentication. So I thought, let&#8217;s just migrate it to LDAP. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> <br />
<code><br />
~# aptitude install slapd libpam-ldap libnss-ldap ldap-utils migrationtools nscd<br />
</code><br />
Enter your rootbinddn and a secret, besides select the ldap protocol version 3. Then open <em>/etc/ldap/ldap.conf</em> and configure it the way needed. As URI take <em>ldap://127.0.0.1</em>. At this point we do not use SSL/TLS, since the SLAPD will only run on the local host and no data will be sent over the network. However, <em>/etc/pam_ldap.conf</em>:<br />
<code><br />
host 127.0.0.1<br />
base [your basedn]<br />
ldap_version 3<br />
rootbinddn [your rootbinddn, usually cn=admin,[base]]<br />
pam_password crypt<br />
nss_initgroups_ignoreusers backup,bin,daemon,dhcp,games,gnats,irc,klog,libuuid,list,lp,mail,man,news,ntp,nx,proxy,root,sshd,statd,sync,sys,syslog,uucp,www-data<br />
</code><br />
<em>/etc/nsswitch.conf</em><br />
<code><br />
passwd:		ldap files<br />
group:		ldap files<br />
shadow:		ldap files</code></p>
<p>hosts:          files dns<br />
networks:       files</p>
<p>protocols:      db files<br />
services:       db files<br />
ethers:         db files<br />
rpc:            db files</p>
<p>netgroup:       nis</p>
<p><strong> Btw:</strong> Don&#8217;t forget to put your secret into /etc/pam_ldap.secret! Anyway, let&#8217;s go on&#8230;<br />
<em>/etc/pam.d/common-account:</em><br />
<code><br />
account sufficient pam_unix.so<br />
account sufficient pam_ldap.so<br />
account required pam_deny.so<br />
</code><br />
<em> /etc/pam.d/common-auth</em><br />
<code><br />
auth sufficient pam_unix.so<br />
auth sufficient pam_ldap.so use_first_pass<br />
auth required pam_deny.so<br />
</code><br />
<em> /etc/pam.d/common-password</em><br />
<code><br />
password   sufficient   pam_unix.so nullok md5 shadow use_authtok<br />
password   sufficient   pam_ldap.so use_first_pass use_authtok md5<br />
password   required     pam_deny.so<br />
</code><br />
The common-session doesn&#8217;t need to be changed on the setup we need. Now, edit <em>/usr/share/migrationtools/migrate_common.ph</em> and change the domain to yours. With the tools (migrate_base, *_passwd, *_group) contained in that directory you can migrate your actualy existing /etc/passwd and /etc/group to your ldap. Or you just create these entries manually. However, now let&#8217;s load the apache modules:<br />
<code><br />
a2enmod ldap<br />
a2enmod authnz_ldap<br />
</code><br />
&#8230; and reconfigure our WebDAV VirtualHost:<br />
<code><br />
...<br />
DAV On<br />
AuthType Basic<br />
AuthName "WebDAV"<br />
AuthBasicProvider ldap<br />
AuthLDAPURL "ldap://127.0.0.1/ou=people,[your base here]"<br />
AuthLDAPRemoteUserIsDN off<br />
ForceType text/plain<br />
Require valid-user<br />
Require ldap-filter &amp;(uid=*)<br />
...<br />
</code><br />
And last but not least, let&#8217;s restart all servics:<br />
<code><br />
/etc/init.d/slapd restart<br />
/etc/init.d/nscd restart<br />
/etc/init.d/apache2 restart<br />
</code><br />
Voila! The authentication of your WebDAV against LDAP should be working now. Now the only thing that&#8217;s left to do, is to remove the user www-data from the shadow group again. And maybe you&#8217;d like to change your LDAP-user&#8217;s passwords:<br />
<code><br />
ldappasswd -x -D cn=admin,[your base here] -W uid=[username],ou=people,[your base here] -S<br />
</code><br />
And the next time, I&#8217;ll show you how you can build yourself an automatic back-scratcher using a wall, glue and a cat.</p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2008/09/07/webdav-over-ssl-using-ldap-with-apache2-on-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebDAV over SSL using PAM with Apache2 on Debian</title>
		<link>http://devilx.net/2008/09/04/webdav-over-ssl-using-pam-with-apache2-on-debian/</link>
		<comments>http://devilx.net/2008/09/04/webdav-over-ssl-using-pam-with-apache2-on-debian/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 23:17:55 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[Linux and stuff ...]]></category>
		<category><![CDATA[New & Cool]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Cool]]></category>
		<category><![CDATA[DAV]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[iDisk]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[PAM]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[WebDAV]]></category>

		<guid isPermaLink="false">http://www.devilx.net/?p=513</guid>
		<description><![CDATA[Phew, what a long title. Whatever. What do we need? First of all, a Debian system. I&#8217;m preffering a Debian Etch &#8216;n Half at this point. On that system, we need an Apache (2) and the PAM authentication module: ~# &#8230; <a href="http://devilx.net/2008/09/04/webdav-over-ssl-using-pam-with-apache2-on-debian/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Phew, what a long title. Whatever. What do we need? First of all, a Debian system. I&#8217;m preffering a Debian Etch &#8216;n Half at this point. On that system, we need an Apache (2) and the PAM authentication module:<br />
<code><br />
~# aptitude install apache2 libapache2-mod-auth-pam<br />
</code><br />
Now, first of all we activate SSL and WebDAV:<br />
<code><br />
~# a2enmod ssl<br />
~# a2enmod dav<br />
~# a2enmod dav_fs<br />
</code><br />
Next, we tell our Apache to listen on 443, for SSL:<br />
<code><br />
echo "Listen 443" &gt;&gt; /etc/apache2/ports.conf<br />
</code><br />
Then, we configure our SSL VirtualHost:<br />
<code><br />
NameVirtualHost *:443<br />
&lt;VirtualHost *:443&gt;<br />
ServerName my.serv.er<br />
ServerAdmin webmaster@serv.er</code></p>
<p>SSLEngine On<br />
SSLCertificateFile /etc/apache2/ssl/my.serv.er.crt<br />
SSLCertificateKeyFile /etc/apache2/ssl/my.serv.er.key<br />
DocumentRoot /var/www/<br />
&lt;Directory /var/www/&gt;<br />
Options Indexes FollowSymLinks MultiViews<br />
AllowOverride None<br />
Order allow,deny<br />
allow from all<br />
&lt;/Directory&gt;</p>
<p>ErrorLog /var/log/apache2/error.log<br />
LogLevel warn<br />
CustomLog /var/log/apache2/access.log combined<br />
ServerSignature On<br />
&lt;/VirtualHost&gt;</p>
<p>The certificate-folder needs to be created and the certificates need to be generated:<br />
<code><br />
~# mkdir /etc/apache2/ssl<br />
~# openssl genrsa -out /etc/apache2/ssl/my.serv.er.key 1024<br />
~# openssl req -new -days 365 -key /etc/apache2/ssl/my.serv.er.key -x509 -out /etc/apache2/ssl/my.serv.er.crt<br />
</code><br />
Next, we add the WebDAV/PAM settings to our SSL-VHost, while <em>/home/pub</em> is the folder we&#8217;d like to publish:<br />
<code><br />
...<br />
DAVLockDB /var/lib/apache2/DAVLockDB<br />
Alias /pub /home/pub/<br />
&lt;Location /pub&gt;<br />
DAV On<br />
AuthType Basic<br />
AuthName "WebDAV"<br />
AuthPAM_Enabled On<br />
#AuthPAM_FallThrough Off<br />
AuthUserFile /etc/shadow<br />
ForceType text/plain<br />
Require valid-user<br />
&lt;/Location&gt;<br />
...<br />
</code><br />
And last but not least, we (unfortunatelly) need to add the user <em>www-data</em> to the group <em>shadow</em>:<br />
<code><br />
adduser www-data shadow<br />
</code><br />
Now we can restart our Apache and enjoy the pleasure of WebDAV. If it should not work, check the permissions you set for the directory you&#8217;re publishing.<br />
And what could this be used for? For example, as self-made iDisk. <img src='http://devilx.net/wp-content/plugins/smilies-themer/Riceballs/smile.png' alt=':-)' class='wp-smiley' /> <br />
Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://devilx.net/2008/09/04/webdav-over-ssl-using-pam-with-apache2-on-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

