<?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>System Network Programming Solution - Linux - windows - centos- security- cpanel - plesk -directadmin helm&#187; Debian</title>
	<atom:link href="http://thegioinguonmo.com/tag/debian/feed/" rel="self" type="application/rss+xml" />
	<link>http://thegioinguonmo.com</link>
	<description>SHARING EVERYTHING</description>
	<lastBuildDate>Mon, 06 Feb 2012 09:45:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How To Manage Apache Resources Limits With mod_slotlimit (Debian Etch)</title>
		<link>http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html</link>
		<comments>http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html#comments</comments>
		<pubDate>Mon, 09 Jan 2012 09:39:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[mod]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=254</guid>
		<description><![CDATA[mod_slotlimit is an Apache module that using dynamic slot allocation algorithm and static rules, can manage resources used for each running site. &#160; 1. Installation In order to compile mod_slotlimit, you will need to have apxs2 (APache eXtension tool) installed and configured with Apache. The follow command will install it: apt-get install apache2-prefork-dev Now we [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="nofollow" target="_blank" href="http://sourceforge.net/projects/mod-slotlimit/" target="_blank">mod_slotlimit</a> is an Apache module that using dynamic slot allocation algorithm and static rules, can manage resources used for each running site.</p>
<p>&nbsp;</p>
<h3>1. Installation</h3>
<p>In order to compile mod_slotlimit, you will need to have apxs2 (APache eXtension tool) installed and configured with Apache.</p>
<p>The follow command will install it:</p>
<p>apt-get install apache2-prefork-dev</p>
<p>Now we download the source package present at http://sourceforge.net/projects/mod-slotlimit/ or download it using wget application and this direct link to the repository:</p>
<p>wget http://kent.dl.sourceforge.net/sourceforge/mod-slotlimit/mod_slotlimit.tar.gz</p>
<p>Next open archive, compile and install module with those commands:</p>
<p>tar zxvf mod_slotlimit.tar.gz<br />
cd mod_slotlimit-1.0<br />
make<br />
make install</p>
<p>Add in the main config file of your web server the following command in order to load mod_slotlimit module.</p>
<p>vi /etc/apache2/httpd.conf</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<blockquote><p>[...]<br />
LoadModule slotlimit_module /usr/lib/apache2/modules/mod_slotlimit.so</p></blockquote>
</td>
</tr>
</tbody>
</table>
<h3>2. Configuration</h3>
<p>Before we are able to write our configuration, we should known what directives are supported by this module.</p>
<p>For more information read mod_slotlimit’s documentation:</p>
<p>AvailableSlotsPercent – Percentage of apache slots available in order to activate dynamic slot allocation algorithm<br />
MaxConnectionsPerSite – Max connections for each running site<br />
LimitSite – Specific site to limit<br />
LimitSiteConnections – Max connections for “LimitSite”<br />
ClientIpLimit – Number of maximum simultaneous connection per IP<br />
ForceVhostName – Force vhost hostname in scoreboard. Useful when vhost hostname do not match site visited, for example if you’re using mod_vhost_alias</p>
<p>Now we open config file of our web server in order to write the configuration:</p>
<p>vi /etc/apache2/apache2.conf</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<blockquote><p>[...]<br />
&lt;IfModule mod_slotlimit.c&gt;<br />
AvailableSlotsPercent 15<br />
MaxConnectionsPerSite 30<br />
LimitSite www.BadSite.xxx<br />
LimitSiteConnections 15<br />
ClientIpLimit 15<br />
ForceVhostName On<br />
&lt;/IfModule&gt;<br />
[...]</p></blockquote>
</td>
</tr>
</tbody>
</table>
<p>Finally we restart Apache:</p>
<p>/etc/init.d/apache2 restart</p>
<h3>3. Links</h3>
<ul>
<li>mod_slotlimit: <a rel="nofollow" target="_blank" href="http://sourceforge.net/projects/mod-slotlimit/" target="_blank">http://sourceforge.net/projects/mod-slotlimit/</a></li>
<li>Apache: <a rel="nofollow" target="_blank" href="http://httpd.apache.org/" target="_blank">http://httpd.apache.org</a></li>
<li>Debian: <a rel="nofollow" target="_blank" href="http://www.debian.org/" target="_blank">http://www.debian.org</a></li>
</ul>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html" title="centos directadmin apache log">centos directadmin apache log</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html" title="directadmin custombuild wsgi">directadmin custombuild wsgi</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html" title="php5-eaccelerator php5-memcache apt-get">php5-eaccelerator php5-memcache apt-get</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html" title="plesk Apache2::Resource">plesk Apache2::Resource</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html" title="sc_pcre c: In function âmsc_pregcomp_exâ: msc_pcre c:70: error: invalid application of âsizeofâ to incomplete type âpcre_extraâ msc_pcre c:74: error: invalid application of âsizeofâ to incomplete type âpcre_extraâ">sc_pcre c: In function âmsc_pregcomp_exâ: msc_pcre c:70: error: invalid application of âsizeofâ to incomplete type âpcre_extraâ msc_pcre c:74: error: invalid application of âsizeofâ to incomplete type âpcre_extraâ</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Host Based Intrusion Detection &#8211; Samhain</title>
		<link>http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html</link>
		<comments>http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html#comments</comments>
		<pubDate>Sun, 08 Jan 2012 15:28:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Samhain]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2197</guid>
		<description><![CDATA[I am not going to ramble on about what host based intrusion detection is or why to use it, as there are plenty of articles already covering those subjects. This article is just to show you how to get Samhain up and running in a client / server configuration with a couple bells and whistles [...]]]></description>
			<content:encoded><![CDATA[<p>I am not going to ramble on about what host based intrusion detection is or why to use it, as there are plenty of articles already covering those subjects. This article is just to show you how to get Samhain up and running in a client / server configuration with a couple bells and whistles thrown in for fun.</p>
<p><strong>I highly recommend you read the entire guide before you start, it will most certainly help.</strong></p>
<p>There is a lot of swapping between client and server as I try my best to confuse you, so stay sharp!</p>
<p>&nbsp;</p>
<h3>Prerequisites</h3>
<p>You will need all the required build tools installed as we are going to compile Samhain. Here is a quick refresher:</p>
<p>Red Hat</p>
<p>yum groupinstall &#8220;Development Tools&#8221;</p>
<p>Debian</p>
<p>apt-get install build-essential</p>
<p><strong>NOTE:</strong> Please keep in mind that development tools on production servers is perhaps not the best of ideas. These packages may further assist the wannebe hacker, fill up precious megabyte or eat your cat. It is recommended to build the required packages on your build server, test them, create rpm / deb package and then deploy said packages on your production environment.</p>
<p>Here is a short check list to follow:</p>
<ol>
<li>You will need MySQL and Apache running on your server. This guide will assume a vanilla MySQL and Apache configuration. I leave it up to the reader to figure out how to install and configure these services on your favourite distribution.</li>
<li>You will need the MySQL development package (generaly mysql-devel) installed for the server side of things.</li>
<li>MySQL must have a root password set. If the MySQL root password is not set, go and do that first. While your at MySQL, you may want to look at this : /usr/bin/mysql_secure_installation</li>
<li>The server and client(s) host name must be fully qualified.</li>
<li>The server and client(s) /etc/host file must be correct (really correct, not Red Hat default correct), and DNS must be working for both forward and reverse lookups.</li>
<li>Port 50888 TCP should be open, or whatever port you set when building.</li>
<li>ImageMagick is required on the client.</li>
</ol>
<p>&nbsp;</p>
<h3>Download And Install</h3>
<p><a rel="nofollow" target="_blank" href="http://www.la-samhna.de/samhain/s_download.html" target="_blank">http://www.la-samhna.de/samhain/s_download.html</a></p>
<p>The above page has a full description of where to download the latest version of Samhain, and how to verify the integrity of the package. <strong>It is critical that the integrity of the package is checked</strong>. If you do not have a good foundation to build on, your house will surely crumble <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Host Based Intrusion Detection   Samhain" class='wp-smiley' title="Host Based Intrusion Detection   Samhain" /> </p>
<p>&nbsp;</p>
<h3>Server Setup</h3>
<p>Yule is the server side component of Samhain.</p>
<p>After you have extracted and checked the package, make sure you are the <strong>root</strong> user, in the top level directory of the unpacked source files.</p>
<p>We start by creating a user for the service, and generating a gpg key as that user:</p>
<pre class="brush:shell">adduser yule
su - yule
gpg --gen-key</pre>
<p>You will be asked the following questions:</p>
<p>gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.<br />
This program comes with ABSOLUTELY NO WARRANTY.<br />
This is free software, and you are welcome to redistribute it<br />
under certain conditions. See the file COPYING for details.<br />
gpg: directory `/home/mytest/.gnupg&#8217; created<br />
gpg: new configuration file `/home/yule/.gnupg/gpg.conf&#8217; created<br />
gpg: WARNING: options in `/home/yule/.gnupg/gpg.conf&#8217; are not yet active during this run<br />
gpg: keyring `/home/yule/.gnupg/secring.gpg&#8217; created<br />
gpg: keyring `/home/yule/.gnupg/pubring.gpg&#8217; created<br />
Please select what kind of key you want:<br />
(1) DSA and Elgamal (default)<br />
(2) DSA (sign only)<br />
(5) RSA (sign only)<br />
Your selection? &lt;&#8211; The default is fine, just press <strong>ENTER</strong><br />
DSA keypair will have 1024 bits.<br />
ELG-E keys may be between 1024 and 4096 bits long.<br />
What keysize do you want? (2048) <strong>4096 </strong>&lt;&#8211; 4096 For the paranoid<br />
Requested keysize is 4096 bits<br />
Please specify how long the key should be valid.<br />
0 = key does not expire<br />
&lt;n&gt; = key expires in n days<br />
&lt;n&gt;w = key expires in n weeks<br />
&lt;n&gt;m = key expires in n months<br />
&lt;n&gt;y = key expires in n years<br />
Key is valid for? (0) <strong>2y </strong>&lt;&#8211; Some may feel 2 years is to long, it&#8217;s up to you &#8230;<br />
Key expires at Sat 15 Dec 2012 22:24:38 GMT<br />
Is this correct? (y/N) <strong>y </strong>&lt;&#8211; If you are happy and you know it clap your hands<br />
You need a user ID to identify your key; the software constructs the user ID<br />
from the Real Name, Comment and Email Address in this form:<br />
&#8220;Heinrich Heine (Der Dichter)&lt;heinrichh@duesseldorf.de&gt;&#8221;</p>
<p>Real name: <strong>yules </strong>&lt;&#8211; Whatever name you want to use<br />
Email address: <strong>yules@you.com </strong> &lt;&#8211; Some e-mail address<br />
Comment: <strong>20 questions </strong> is a fun game<br />
You selected this USER-ID:<br />
&#8220;yules (20 questions) &lt;yules@you.com&gt;&#8221;</p>
<p>Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? <strong>O </strong>&lt;&#8211; If you are happy, OK it<br />
You need a Passphrase to protect your secret key.</p>
<p>Enter passphrase: <strong>This is a long passphrase ! </strong>&lt;&#8211; Enter a strong passphrase<br />
We need to generate a lot of random bytes. It is a good idea to perform<br />
some other action (type on the keyboard, move the mouse, utilize the<br />
disks) during the prime generation; this gives the random number<br />
generator a better chance to gain enough entropy.<br />
++++++++++++++++++++++++++++++++++++++++.++++++++++.++++++++++.++++++++++..+++++.+++++++++++++++.++++++++++.++++++++++++++++++++++++++++++<br />
++++++++++&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..+++++</p>
<p>Not enough random bytes available. Please do some other work to give<br />
the OS a chance to collect more entropy! (Need 284 more bytes)</p>
<p>gpg: /home/yule/.gnupg/trustdb.gpg: trustdb created<br />
gpg: key B7043C9A marked as ultimately trusted<br />
public and secret key created and signed.</p>
<p>gpg: checking the trustdb<br />
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model<br />
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u<br />
gpg: next trustdb check due at 2012-12-15<br />
pub 1024D/B7043C9A 2010-12-16 [expires: 2012-12-15]<br />
Key fingerprint = 421E CFE8 533E 017F 95C8 170A DB54 28E7 B704 3C9A<br />
uid yules (20 questions) &lt;yules@you.com&gt;<br />
sub 4096g/EB230E29 2010-12-16 [expires: 2012-12-15]</p>
<p>Quit this shell, so that we are back to the root user.</p>
<p>exit</p>
<p>So now we have a gpg key, lets get on with building the packages.</p>
<p>The default gpg binary does not support the TIGER192 checksum. As such, we first build a vanilla Samhain binary so that we can get that capability from the Samhain binary.</p>
<pre class="brush:shell">./configure
make</pre>
<p>Right, now we build the real thing &#8230;</p>
<pre class="brush:shell">./configure --with-gpg=/usr/bin/gpg --enable-network=server --with-database=mysql --enable-xml-log --with-port=50888 --enable-identity=yule
make
make install</pre>
<p>At this point, the following should come up:</p>
<p>You need to sign the configuration file now<br />
/usr/bin/gpg -a &#8211;clearsign yulerc<br />
using &#8211;homedir /home/yule/.gnupg<br />
gpg: WARNING: unsafe ownership on homedir `/home/yule/.gnupg&#8217;<br />
You need a passphrase to unlock the secret key for<br />
user: &#8220;yules (20 questions) &lt;yules@you.com&gt;&#8221;<br />
1024-bit DSA key, ID BAFB6B91, created 2010-12-21<br />
Enter passphrase: <strong>This is a long passphrase ! </strong>&lt;&#8211; This is the passphrase we set earlier.</p>
<p><strong>Side note: </strong> I am unsure why gpg is complaining about the ownership, as the permissions is just fine.</p>
<p>Now install the initialization script, set up MySQL user / permission and fix some file permissions.</p>
<pre class="brush:shell">make install-boot
mysql -p &lt; sql_init/samhain.mysql.init
echo "grant select, insert on samhain.log to samhain@localhost IDENTIFIED BY 'samhain';" | mysql -p &lt;-- This will ask for your root MySQL password.
echo "FLUSH PRIVILEGES;" | mysql -p &lt;-- This will ask for your root MySQL password.
chown yule:yule /var/log/yule
chown yule:yule /etc/yulerc
chown yule:yule /var/lib/yule</pre>
<p>Set yule to start at boot.</p>
<p>Red Hat</p>
<pre class="brush:shell">chkconfig --add yule
chkconfig yule on</pre>
<p>Debian</p>
<p>update-rc.d yule defaults</p>
<p>Start yule with:</p>
<p>/etc/init.d/yule start</p>
<p>Yule may complain with something like :</p>
<p>&lt;log sev=&#8221;WARN&#8221; tstamp=&#8221;2010-12-21T11:46:42+0000&#8243; msg=&#8221;Invalid line 102 in configuration file: incorrect format, unrecognized option, or missing section header&#8221; /&gt;<br />
&lt;log sev=&#8221;WARN&#8221; tstamp=&#8221;2010-12-21T11:46:42+0000&#8243; msg=&#8221;Invalid line 106 in configuration file: incorrect format, unrecognized option, or missing section header&#8221; /&gt;</p>
<p>However, the service should start fine. These two warnings are due to the [Database] header being commented out. Either uncomment it, or comment said two lines out. They are true by default.</p>
<p>For a list of configuration options with full explanations, see <a rel="nofollow" target="_blank" href="http://la-samhna.de/samhain/manual/compilation-options.html" target="_blank">http://la-samhna.de/samhain/manual/compilation-options.html</a></p>
<p>&nbsp;</p>
<h3>Apache Configuration</h3>
<p>Add the following in:</p>
<p>Red Hat</p>
<p>/etc/httpd/conf.d/samhain.conf</p>
<p>Debian</p>
<p>/etc/apache2/conf.d/samhain.conf</p>
<pre>&lt;Directory "/var/log/yule/"&gt;
   Options ExecCGI
   AllowOverride None
   Order allow,deny
   Allow from all
&lt;/Directory&gt;
Alias /yule.html "/var/log/yule/yule.html"</pre>
<p>Then reload Apache with:</p>
<p>Red Hat</p>
<p>service httpd restart</p>
<p>Debian</p>
<p>/etc/init.d/apache2 restart</p>
<p>Now visit http://yourserver/yule.hml</p>
<h3>Client Setup</h3>
<div></div>
<p>Log in on the server you wish to install the Samhain client on and make sure you are the <strong>root</strong> user. Also make sure you have all the essential build packages installed, refer to the overview for installation of these essential build packages.</p>
<p>First, we need a gpg key for root.</p>
<p>See previous example for detailed steps.</p>
<p>gpg &#8211;gen-key</p>
<p>Now we need to pull out the fingerprint for this key, so that we can use it when building the Samhain binary.</p>
<p>MY_FP=`gpg &#8211;fingerprint root | grep fingerpr | sed &#8216;s/ //g&#8217; | awk &#8216;BEGIN { FS = &#8220;=&#8221; } ; {print $2}&#8217;`</p>
<p>As before, we need TIGER192 checksum capability first.</p>
<p>./configure<br />
make</p>
<p>Now, since we are having a bit of fun, we are going to change the name of the binary and process. Classical security by obscurity. I&#8217;m picking the name <strong>john</strong>, a general purpose password cracker. Pick a name that will not stand out in a process listing and shout out &#8220;THIS IS A HIDS PROCESS !!!!11&#8243;. Then again, know how much/little a name change actually hides what this binary does before you rely on it to hide you&#8217;re HIDS from a l33t haxor.</p>
<p>We further specify that the configuration and data files should be pulled from the server. If you want to take this one step further, look into the following compile options : &#8211;enable-khide,&#8211;enable-suidcheck and &#8211;with-kcheck=/path/to/System.map</p>
<p>Make sure to change <strong>IP_OF_YOUR_SERVER</strong> to the actual IP address of your Yule server.</p>
<p>./configure &#8211;with-gpg=/usr/bin/gpg &#8211;enable-network=client &#8211;with-config-file=REQ_FROM_SERVER &#8211;with-data-file=REQ_FROM_SERVER/var/lib/john/john \<br />
&#8211;enable-stealth=129 &#8211;enable-install-name=john &#8211;enable-srp &#8211;with-fp=$MY_FP &#8211;with-port=50888 \<br />
&#8211;with-logserver=<strong>IP_OF_YOUR_SERVER</strong> &#8211;with-sender=john<br />
make</p>
<p>Make the required directories, copy the binary over (with the correct name) and put the initialization script in place.</p>
<pre class="brush:shell">mkdir /var/lib/john/
cp init/samhain.startLinux /etc/init.d/john
chmod 744 /etc/init.d/john
cp samhain /usr/local/sbin/john
cp samhain_setpwd /usr/local/sbin/john_setpwd
cp samhain_stealth /usr/local/sbin/john_stealth
cd /usr/local/sbin</pre>
<p>Set the password and overwrite the binary.</p>
<pre class="brush:shell">/usr/local/sbin/john_setpwd john jingle 161718abcd212324
mv john.jingle john</pre>
<p>&#8220;jingle&#8221; Does not matter, it&#8217;s just the append and the number is what you want in 16 bit 0-9, A-F (A.K.A HEX). You can use yule -G on the server to generate a random number for you.</p>
<p>The output should look something like:</p>
<p>INFO old password found<br />
INFO replaced: f7c312aaaa12c3f7 by: 161718abcd212324<br />
INFO finished</p>
<p>Change the description in the initialization script.</p>
<p>sed -i &#8216;s/File Integrity Checking/Password Cracking/&#8217; /etc/init.d/john</p>
<p>Make sure the daemon starts at boot.</p>
<p>Red Hat</p>
<pre class="brush:shell">chkconfig --add john
chkconfig john on</pre>
<p>Debian</p>
<pre class="brush:shell">update-rc.d john defaults</pre>
<p>&nbsp;</p>
<h3>A Little Work On The Server</h3>
<p>The HEX key we just embedded in the client binary, we need it now to tell the server about that client.</p>
<p>/usr/local/sbin/yule -P 161718abcd212324 | sed &#8216;s/HOSTNAME/<strong>CliENT_HOSTNAME_HERE</strong>/&#8217; &gt;&gt; /etc/yulerc &lt;&#8211; Make sure to put the client host name (FQDN) in.</p>
<p>Edit /etc/yulerc and move the key above the GPG signature.</p>
<p>For example, the last couple of lines of /etc/yulerc mihgt look like this:</p>
<pre># Client=HOSTNAME@00000000@C39F0EEFBC64E4A8BBF72349637CC07577F714B420B62882
# Client=HOSTNAME@8F81BA58956F8F42@8932D08C49CA76BD843C51EDD1D6640510FA032A7A2403E572BBDA2E5C6B753991CF7E091141D20A2499C5CD3E14C1639D17482E14E1548E5246ACF4E7193D524CDDAC9C9D6A9A36C596B4ECC68BEB0C5BB7082224946FC98E3ADE214EA1343E2DA8DF4229D4D8572AD8679228928A787B6E5390D3A713102FFCC9D0B2188C92
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFNEI7oerU1Wrr7a5ERAkWqAJ9sZEuRLp8rPOjXdUokT03bEfjGuwCfa+Tr
pDK7/KmGj3Hx8vRMufxNx7A=
=zI4S
-----END PGP SIGNATURE-----
Client=rhc2.sys.local@F1DF72033799940C@37FC42534A812B2351007A24820537466495F97ED352EFC1D9DCAEACBBF5CB98AEF183057CE6D101151F112693C2DAE361435CED1C95E822272FE287A56B4D38EE91B00830A56AE2F26E4738DF099CAEF3372342BE0ACDB78C12FD176EED1FBA376A0399537F848B6FA9AD4E61E6C771A5566F43D62C1F9836AB976CB1111545</pre>
<p>We need to change that to look like this:</p>
<pre># Client=HOSTNAME@00000000@C39F0EEFBC64E4A8BBF72349637CC07577F714B420B62882
# Client=HOSTNAME@8F81BA58956F8F42@8932D08C49CA76BD843C51EDD1D6640510FA032A7A2403E572BBDA2E5C6B753991CF7E091141D20A2499C5CD3E14C1639D17482E14E1548E5246ACF4E7193D524CDDAC9C9D6A9A36C596B4ECC68BEB0C5BB7082224946FC98E3ADE214EA1343E2DA8DF4229D4D8572AD8679228928A787B6E5390D3A713102FFCC9D0B2188C92
Client=rhc2.sys.local@F1DF72033799940C@37FC42534A812B2351007A24820537466495F97ED352EFC1D9DCAEACBBF5CB98AEF183057CE6D101151F112693C2DAE361435CED1C95E822272FE287A56B4D38EE91B00830A56AE2F26E4738DF099CAEF3372342BE0ACDB78C12FD176EED1FBA376A0399537F848B6FA9AD4E61E6C771A5566F43D62C1F9836AB976CB1111545
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFNEI7oerU1Wrr7a5ERAkWqAJ9sZEuRLp8rPOjXdUokT03bEfjGuwCfa+Tr
pDK7/KmGj3Hx8vRMufxNx7A=
=zI4S
-----END PGP SIGNATURE-----</pre>
<p>The following steps are always required when you&#8217;ve made changes to the configuration files.</p>
<p>Edit /etc/yulerc and remove the first 3 and last 7 lines, this is the GPG/PGP signature.</p>
<p>Example:</p>
<pre>-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
There will be another line here later on.
#####################################################################
#
# Configuration file template for yule.
#
#####################################################################

Lots of Yule configuration removed ...

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFNEI7oerU1Wrr7a5ERAkWqAJ9sZEuRLp8rPOjXdUokT03bEfjGuwCfa+Tr
pDK7/KmGj3Hx8vRMufxNx7A=
=zI4S
-----END PGP SIGNATURE-----</pre>
<p>Then sign the configuration file again with the user yule and copy the file in place as the <strong>root</strong> user:</p>
<p>su &#8211; yule<br />
gpg -o yulerc.asc -a &#8211;clearsign &#8211;not-dash-escaped /etc/yulerc &lt;&#8211; Type in the passphrase we set earlier.<br />
exit<br />
/bin/mv /home/yule/yulerc.asc /etc/yulerc<br />
service yule reload</p>
<p>&nbsp;</p>
<h3>A Little More Work On The Client</h3>
<p>We will need to create the configuration file and embed it into a postscript file. Make sure you have Imagemagick installed, as you will need convert.</p>
<p>Go and download a good looking picture like <a rel="nofollow" target="_blank" href="http://apod.nasa.gov/apod/image/0903/tycho_chandra_big.jpg" target="_blank">http://apod.nasa.gov/apod/image/0903/tycho_chandra_big.jpg</a>. You will want at least a 200K size image, if not larger, to hide the configuration file in it. Also, it is handy to have an original configuration file as backup.</p>
<p><strong>NOTE:</strong> The following steps has to be done each time you wish to modify the configuration file of the client.</p>
<p>cd <strong>TOPLEVEL_OF_SOURCE_DIR</strong><br />
wget http://apod.nasa.gov/apod/image/0903/tycho_chandra_big.jpg<br />
convert tycho_chandra_big.jpg tycho_chandra_big.ps &lt;&#8211; Convert the JPG to a postscript file.<br />
cp samhainrc.linux rc.`hostname` &lt;&#8211; Get a default configuration.<br />
gpg -a &#8211;clearsign &#8211;not-dash-escaped rc.`hostname` &lt;&#8211; Clear sign the configuration.<br />
mv rc.`hostname`.asc rc.`hostname` &lt;&#8211; Move the signed file to the normal file name for the configuration file.<br />
/usr/local/sbin/john_stealth -s tycho_chandra_big.ps rc.`hostname`&lt;&#8211; Steganographically hide the configuration file inside the postscript file.<br />
rm rc.`hostname` tycho_chandra_big.* &lt;&#8211; Remove the &#8220;clean&#8221; files.</p>
<p>Make sure that the resulting postscript file is not very large, or Samhain will fail to download it. I do not have exact numbers, but from experience 66Mb is too large <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Host Based Intrusion Detection   Samhain" class='wp-smiley' title="Host Based Intrusion Detection   Samhain" /> </p>
<p>Now copy the file over to your server:</p>
<p>scp tycho_chandra_big.ps <strong>YULE_SERVER</strong>:~/rc.`hostname` &lt;&#8211; Assuming scp with root. In real life, please do not open ssh for root.</p>
<p>Back to the <strong>server</strong>:</p>
<p>cp ~/rc.<strong>CliENT_FQDN</strong> /var/lib/yule/ &lt;&#8211; Make sure to fill in the clients FQDN.<br />
chown yule:yule /var/lib/yule/rc.<strong>CliENT_FQDN</strong> &lt;&#8211; Make sure to fill in the clients FQDN.</p>
<p>Back to the <strong>client</strong>:</p>
<p>/usr/local/sbin/john -t init -p info</p>
<p>This will now build the database in /var/lib/john. Don&#8217;t worry about all the output at this stage, we are just getting things up and running now.</p>
<p>After we have a database, we have to sign it and copy it over to the server.</p>
<p>gpg -a &#8211;clearsign &#8211;not-dash-escaped /var/lib/john/john<br />
scp /var/lib/john/john.asc <strong>YULE_SERVER</strong>:~/file.`hostname` &lt;&#8211; Assuming scp with root. In real life, please do not open ssh for root.<br />
rm /var/lib/john/john*</p>
<p>Back to the <strong>server</strong>, we move this file to the correct place:</p>
<p>mv ~/file.<strong>CliENT_FQDN</strong> /var/lib/yule<br />
chown yule:yule /var/lib/yule/*</p>
<p>It is important that all configuration files start with rc and all database files start with file.</p>
<p>&nbsp;</p>
<h3>Troubleshooting</h3>
<p>Trouble, what trouble?</p>
<ol>
<li>Start with tailing the log file on the server : tail -f /var/log/yule/yule_log</li>
<li>Change the log level in /etc/yulerc to info or above (always remember to re-sign the configuration file as described).</li>
<li>Recompile without some of the options to test.</li>
<li>Have a look at this link : <a rel="nofollow" target="_blank" href="http://www.la-samhna.de/samhain/s_documentation.html" target="_blank">http://www.la-samhna.de/samhain/s_documentation.html</a></li>
</ol>
<p>&nbsp;</p>
<h3>Clean Up</h3>
<p>Now we don&#8217;t want to be leaving breadcrumbs behind us, some clean up is required.</p>
<ol>
<li>Delete all the source files and any tarballs that was downloaded if you built directly on a production server.</li>
<li>Delete <strong>all</strong> entries from your shell history.</li>
<li>Remove all the development packages that was installed if you built directly on a production server.</li>
<li>Remove /usr/local/sbin/john_stealth and /usr/local/sbin/john_setpwd.</li>
</ol>
<p>Basically, get rid of any evidence of what you just did.</p>
<p>&nbsp;</p>
<h3>Tuning</h3>
<p>Arguably, this is where the guide should start. Samhain does not understand what is right and what is wrong for this particular server. As such, you need to tune it. The simplest way is to build Samhain without any options what so ever like:</p>
<p>./configure<br />
make<br />
mkdir /var/lib/samhain/</p>
<p>Put the configuration file in /etc/samhainrc, and run</p>
<p>samhain -t init -p info &gt; my_output 2&gt;&amp;1</p>
<p>You can then examine the output file and make the appropriate changes to the Samhain configuration file. The database will be created in /var/lib/samhain. Do not run samhain -t init more than once without deleting the database.</p>
<p>Once you are happy with the configuration, build Samhain in server / client mode.</p>
<p><strong>NOTE:</strong> It is however rather important that you profile your server and tune Samhain before it is connected to the Internet.</p>
<p>&nbsp;</p>
<h3>Honey Pot!</h3>
<p>Now for a bit of fun. We really <strong>do</strong> want intruders to let us know they are on our system. So, we create 2 (or more) files with catchy names and tell Samhain to monitor those files for <strong>any</strong> changes (that includes access times).</p>
<p>cp /etc/passwd /home/cracked_passwords<br />
cp /etc/hosts /home/customers/credit_cards_2008.xls</p>
<p>Now, in Samhain&#8217;s configuration file, there is a section called [IgnoreNone], add these files in that section. You can test this by simply catting those files and then run the check. The output should be something like:</p>
<p>CRIT : [2009-04-27T21:33:11+0100] msg=&lt;POliCY [User1] &#8212;&#8212;&#8211;T-&gt;, path=&lt;/home/cracked_passwords&gt;, atime_old=&lt;[2009-04-27T20:25:39]&gt;,<br />
atime_new=[2009-04-27T20:32:37]&gt;,</p>
<p>&nbsp;</p>
<h3>Nagios Integration</h3>
<p>I have not tested this yet, this is just on top of my head, so it may well be very wrong.</p>
<p>So now we have alerts for when things go wrong. By default, the standard Nagios plugin pack ships with check_log. Our Nagios check command will look something like:</p>
<pre>check_log -F /var/log/yule_log -O /var/log/yule/yule_nagios_diff_log -q "ERROR|CRIT|ALERT"</pre>
<p>You will need to modify how to alert on this particular service. By default Nagios will check 3 times before alerting, but with check_log you will never get an alert. The reason is as follows:</p>
<ol>
<li>check 1: The check returns an error, as it spotted your query (lets say CRIT) in the difference from the old stored log file and the current running log file. The check command now updates the old stored log file.</li>
<li>check 2: There is no longer a difference between the old stored log file and the current running one, thus the check passes OK.</li>
</ol>
<p>Either modify Nagios to alert after a single failure, or write a wrapper specifically for this check to create a lock file somewhere. You then check for this lock file and alert if it exists. Both approaches have some down sides. If we alert on a single check, be prepared for false alerts due to packet loss or a shift in the force. If we create a lock file, you will have to manually remove it.</p>
<p>Now that we are monitoring the log file for changes detected, we also need to monitor that the client process is still up and running. Of course, you will also want to monitor that the server process is running all the time.</p>
<p>I am sure someone will come up with a better way of Nagios integration, like I said, this is just thinking out loud.</p>
<p>&nbsp;</p>
<h3>What It All Means</h3>
<p>At the end of the day, the clear text configuration of each machine being monitored, is neither kept on the client nor on the server. The clear text configuration files should be kept on a different machine inside an encrypted partition.</p>
<p>Nagios makes sure we are alerted of anything (via e-mail or SMS) and hopefully, an intruder will bite on the honey so that we can see him, potentially, even quicker.</p>
<p>Further more, you can not access any help files (such as ./samhain &#8211;help or man pages) to indicate that there is a HIDS running on the client.</p>
<p>Of course, if you get access to the server, you can see all the clients who logs in. There are further compiler options so that the logs are also encrypted.</p>
<p>&nbsp;</p>
<h3>Layers</h3>
<p>In the voice of Shrek: &#8220;Security is like an onion, it has many layers.&#8221; Remember that host based intrusion detection is just one more layer in this onion. You also need a good firewall, network intrusion detection, monitoring, centralised logging, log analysis, TCP wrappers, SELinux (or some other mandatory access control mechanism), brute force blockers like fail2ban and much more.</p>
<p>As an example of this, the entire host based intrusion detection is rendered moot if the hacker just kills the process and you are not using monitoring to make sure that the service is running.</p>
<p>Please do not hesitate to contact me with any corrections or improvements or even some constructive criticism. <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Host Based Intrusion Detection   Samhain" class='wp-smiley' title="Host Based Intrusion Detection   Samhain" /> </p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="/samhain-install sh: error: cannot find signed file yulerc asc">/samhain-install sh: error: cannot find signed file yulerc asc</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="step by step configuration of samhain in linux">step by step configuration of samhain in linux</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="set up samhianrc to use port 50888">set up samhianrc to use port 50888</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain windows client">samhain windows client</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain trusted userid">samhain trusted userid</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain logs to yule server">samhain logs to yule server</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain cpanel">samhain cpanel</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain configuration">samhain configuration</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain and mysql setup">samhain and mysql setup</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="red hat samhain">red hat samhain</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Move or migrate user accounts from old Linux server to a new Linux server</title>
		<link>http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html</link>
		<comments>http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html#comments</comments>
		<pubDate>Tue, 27 Dec 2011 04:39:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[passwd]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=86</guid>
		<description><![CDATA[Q. How do I Move or migrate user accounts to from old Linux server a new Cent OS Linux server including mails? This new system a fresh installation. A. You can migrate users from old Linux server to new Linux sever with standard commands such as tar, awk, scp and others. This is also useful [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color: #ff0000;">Q.</span></strong> How do I Move or migrate user accounts to from old Linux server a new Cent OS Linux server including mails? This new system a fresh installation.</p>
<p><strong><span style="color: #008000;">A.</span></strong> You can migrate users from old Linux server to new Linux sever with standard commands such as tar, awk, scp and others. This is also useful if you are using old Linux distribution such as Redhat 9 or Debian 2.x.</p>
<p>&nbsp;</p>
<p>Following files/dirs are required for traditional Linux user management:<br />
* <strong><a rel="nofollow" target="_blank" href="http://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/">/etc/passwd</a></strong> – contains various pieces of information for each user account</p>
<p>* <strong><a rel="nofollow" target="_blank" href="http://www.cyberciti.biz/faq/understanding-etcshadow-file/">/etc/shadow</a></strong> – contains the encrypted password information for user’s accounts and optional the password aging information.</p>
<p>* <strong><a rel="nofollow" target="_blank" href="http://www.cyberciti.biz/faq/understanding-etcgroup-file/">/etc/group</a></strong> – defines the groups to which users belong</p>
<p>* <strong>/etc/gshadow</strong> – group shadow file (contains the encrypted password for group)</p>
<p>* <strong>/var/spool/mail</strong> – Generally user emails are stored here.</p>
<p>* <strong>/home</strong> – All Users data is stored here.</p>
<p>You need to backup all of the above files and directories from old server to new Linux server.</p>
<h3>Commands to type on old Linux system</h3>
<p>First create a tar ball of old uses (old Linux system). Create a directory:<br />
<code># mkdir /root/move/</code><br />
Setup UID filter limit:<br />
<code># export UGIDLIMIT=500</code><br />
Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)<br />
<code># awk -v LIMIT=$UGIDLIMIT -F: '($3&gt;=LIMIT) &amp;&amp; ($3!=65534)' /etc/passwd &gt; /root/move/passwd.mig</code><br />
Copy /etc/group file:<br />
<code># awk -v LIMIT=$UGIDLIMIT -F: '($3&gt;=LIMIT) &amp;&amp; ($3!=65534)' /etc/group &gt; /root/move/group.mig</code><br />
Copy /etc/shadow file:<br />
<code># awk -v LIMIT=$UGIDLIMIT -F: '($3&gt;=LIMIT) &amp;&amp; ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow &gt; /root/move/shadow.mig</code><br />
Copy /etc/gshadow (rarely used):<br />
<code># cp /etc/gshadow /root/move/gshadow.mig</code><br />
Make a backup of /home and /var/spool/mail dirs:<br />
<code># tar -zcvpf /root/move/home.tar.gz /home<br />
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail</code></p>
<p>Where,</p>
<ul>
<li>Users that are added to the Linux system always start with UID and GID values of as specified by Linux distribution or set by admin. Limits according to different Linux distro:
<ul>
<li><strong>RHEL/CentOS/Fedora Core</strong> : Default is 500 and upper limit is 65534 (/etc/libuser.conf).</li>
<li><strong>Debian and Ubuntu Linux</strong> : Default is 1000 and upper limit is 29999 (/etc/adduser.conf).</li>
</ul>
</li>
<li>You should never ever create any new system user accounts on the newly installed Cent OS Linux. So above awk command filter out UID according to Linux distro.</li>
<li><strong>export UGIDLIMIT=500 </strong> – setup UID start limit for normal user account. Set this value as per your Linux distro.</li>
<li><strong>awk -v LIMIT=$UGIDLIMIT -F: ‘($3&gt;=LIMIT) &amp;&amp; ($3!=65534)’ /etc/passwd &gt; /root/move/passwd.mig</strong> – You need to pass UGIDLIMIT variable to awk using -v option (it assigns value of shell variable UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field separator to : . Finally awk read each line from /etc/passwd, filter out system accounts and generates new file /root/move/passwd.mig. Same logic is applies to rest of awk command.</li>
<li><strong>tar -zcvpf /root/move/home.tar.gz /home</strong> – Make a backup of users /home dir</li>
<li><strong>tar -zcvpf /root/move/mail.tar.gz /var/spool/mail</strong> – Make a backup of users mail dir</li>
</ul>
<p>Use scp or usb pen or tape to copy /root/move to a new Linux system.<br />
<code># scp -r /root/move/* user@new.linuxserver.com:/path/to/location</code></p>
<h3>Commands to type on new Linux system</h3>
<p>First, make a backup of current users and passwords:<br />
<code># mkdir /root/newsusers.bak<br />
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak<br />
</code><br />
Now restore passwd and other files in /etc/<br />
<code># cd /path/to/location<br />
# cat passwd.mig &gt;&gt; /etc/passwd<br />
# cat group.mig &gt;&gt; /etc/group<br />
# cat shadow.mig &gt;&gt; /etc/shadow<br />
# /bin/cp gshadow.mig /etc/gshadow</code></p>
<p>Please note that you must use <strong>&gt;&gt;</strong> (append) and not <strong>&gt;</strong> (create) shell redirection.</p>
<p>Now copy and extract home.tar.gz to new server /home<br />
<code># cd /<br />
# tar -zxvf /path/to/location/home.tar.gz</code></p>
<p>Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail<br />
<code># cd /<br />
# tar -zxvf /path/to/location/mail.tar.gz</code></p>
<p>Now reboot system; when the Linux comes back, your user accounts will work as they did before on old system:<br />
<code># reboot</code></p>
<p>Please note that if you are new to Linux perform above commands in a sandbox environment. Above technique can be used to UNIX to UNIX OR UNIX to Linux account migration. You need to make couple of changes but overall the concept remains the same.</p>
<h3>Further readings</h3>
<ul>
<li>Read man pages of awk, passwd(5), shadow(5), group(5), tar command</li>
</ul>
<p>Updated for accuracy.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="debian squeeze lighttpd fast-cgi jail wont start">debian squeeze lighttpd fast-cgi jail wont start</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="using tcpdump centos thegioinguonmo">using tcpdump centos thegioinguonmo</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="debian or centos for home file server">debian or centos for home file server</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="flush bind plesk debian">flush bind plesk debian</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="how to allow plesk user to execute a command">how to allow plesk user to execute a command</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="migrate user accounts linux centos">migrate user accounts linux centos</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="mover home tar">mover home tar</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Install A Complete LEMP (Linux &#8211; EngineX (Nginx HTTP SERVER) &#8211; Mysql &#8211; PHP) Server (Not LAMP&#8230;) On Ubuntu/Debian</title>
		<link>http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html</link>
		<comments>http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html#comments</comments>
		<pubDate>Tue, 20 Dec 2011 16:39:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[yourdomain]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=17</guid>
		<description><![CDATA[This HowTo will describe the setup of an efficient http server and mail server for small or medium configurations (as low as 96 mb). So this config is ideal for a small VPS. You can find a good choice of cheap and performant VPS (XEN) at x&#124;encon, a german hosting company. they provide many scalable [...]]]></description>
			<content:encoded><![CDATA[<p>This HowTo will describe the setup of an efficient http server and mail server for small or medium configurations (as low as 96 mb). So this config is ideal for a small VPS. You can find a good choice of cheap and performant VPS (XEN) at <a rel="nofollow" target="_blank" href="http://www.xencon.net/" target="_blank">x|encon</a>, a german hosting company. they provide many scalable VPS solutions with pre-installed Debian and Ubuntu disc images.</p>
<p>Why LEMP instead of LAMP? NGINX is a great replacement for Apache with very low memory footprint and great stability.</p>
<p>Note: i will use the name yourdomain.com for all configurations on a fresh minimal installation of Ubuntu Feisty Fawn server edition.</p>
<p>We will have to install first Postfix to deal with emails and then Dovecot to deliver them with pop3 only (imap uses too much memory). But before that, let&#8217;s install some useful tools we need:</p>
<p>apt-get install wget telnet build-essential</p>
<h3>1. Installation of Postfix</h3>
<p>apt-get install postfix libsasl2 sasl2-bin libsasl2-modules libdb3-util procmail</p>
<p>Now the beautiful blue screen will appear and Postfix will ask you some questions. Answer as follow:</p>
<p>General type of configuration? &lt;&#8211; Internet Site<br />
Mail name? &lt;&#8211; yourdomain.com</p>
<p>Then run:</p>
<p>dpkg-reconfigure postfix</p>
<p>Again, you&#8217;ll be asked some questions:</p>
<p>General type of configuration? &lt;&#8211; Internet Site<br />
Where should mail for root go &lt;&#8211; [blank]<br />
Mail name? &lt;&#8211; yourdomain.com<br />
Other destinations to accept mail for? (blank for none) &lt;&#8211; yourdomain.com, localhost.yourdomain.com, localhost.localdomain, localhost<br />
Force synchronous updates on mail queue? &lt;&#8211; No<br />
Local networks? &lt;&#8211; 127.0.0.0/8<br />
Use procmail for local delivery? &lt;&#8211; Yes<br />
Mailbox size limit &lt;&#8211; 0<br />
Local address extension character? &lt;&#8211; +<br />
Internet protocols to use? &lt;&#8211; all</p>
<p>Type then the following commands (you can copy everything below and paste it in your terminal in one row, it will work but don&#8217;t forget to hit enter to validate the last command):</p>
<p>postconf -e &#8216;smtpd_sasl_local_domain =&#8217;<br />
postconf -e &#8216;smtpd_sasl_auth_enable = yes&#8217;<br />
postconf -e &#8216;smtpd_sasl_security_options = noanonymous&#8217;<br />
postconf -e &#8216;broken_sasl_auth_clients = yes&#8217;<br />
postconf -e &#8216;smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination&#8217;<br />
postconf -e &#8216;inet_interfaces = all&#8217;<br />
echo &#8216;pwcheck_method: saslauthd&#8217; &gt;&gt; /etc/postfix/sasl/smtpd.conf<br />
echo &#8216;mech_list: plain login&#8217; &gt;&gt; /etc/postfix/sasl/smtpd.conf</p>
<p>Now we have to create the certificates for TLS that will be available both for Postfix and Dovecot:</p>
<p>mkdir /etc/ssl/yourdomain (the folder name can be of course anything such as the name of your mother&#8230;)<br />
cd /etc/ssl/yourdomain<br />
openssl genrsa -des3 -rand /etc/hosts -out yourdomain.key 1024</p>
<p>chmod 600 yourdomain.key<br />
openssl req -new -key yourdomain.key -out yourdomain.csr</p>
<p>openssl x509 -req -days 3650 -in yourdomain.csr -signkey yourdomain.key -out yourdomain.crt</p>
<p>openssl rsa -in yourdomain.key -out yourdomain.key.unencrypted</p>
<p>mv -f yourdomain.key.unencrypted yourdomain.key<br />
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650</p>
<p>Next we configure Postfix for TLS:</p>
<p>postconf -e &#8216;smtpd_tls_auth_only = no&#8217;<br />
postconf -e &#8216;smtp_use_tls = yes&#8217;<br />
postconf -e &#8216;smtpd_use_tls = yes&#8217;<br />
postconf -e &#8216;smtp_tls_note_starttls_offer = yes&#8217;<br />
postconf -e &#8216;smtpd_tls_key_file = /etc/ssl/yourdomain/yourdomain.key&#8217;<br />
postconf -e &#8216;smtpd_tls_cert_file = /etc/ssl/yourdomain/yourdomain.crt&#8217;<br />
postconf -e &#8216;smtpd_tls_CAfile = /etc/ssl/yourdomain/cacert.pem&#8217;<br />
postconf -e &#8216;smtpd_tls_loglevel = 1&#8242;<br />
postconf -e &#8216;smtpd_tls_received_header = yes&#8217;<br />
postconf -e &#8216;smtpd_tls_session_cache_timeout = 3600s&#8217;<br />
postconf -e &#8216;tls_random_source = dev:/dev/urandom&#8217;<br />
postconf -e &#8216;myhostname = yourdomain.com&#8217;</p>
<p>Restart Postfix:</p>
<p>/etc/init.d/postfix restart</p>
<p>Authentication will be done by saslauthd. We have to change a few things to make it work properly. Because Postfix runs chrooted in /var/spool/postfix we have to do the following:</p>
<p>mkdir -p /var/spool/postfix/var/run/saslauthd</p>
<p>Now we have to edit /etc/default/saslauthd in order to activate saslauthd. Set START to yes and change the line OPTIONS=&#8221;-c&#8221; to OPTIONS=&#8221;-c -m /var/spool/postfix/var/run/saslauthd -r&#8221;:</p>
<p>vi /etc/default/saslauthd</p>
<pre>#
# Settings for saslauthd daemon
#
# Should saslauthd run automatically on startup? (default: no)
START=yes
# Which authentication mechanisms should saslauthd use? (default: pam)
#
# Available options in this Debian package:
# getpwent  -- use the getpwent() library function
# kerberos5 -- use Kerberos 5
# pam       -- use PAM
# rimap     -- use a remote IMAP server
# shadow    -- use the local shadow password file
# sasldb    -- use the local sasldb database file
# ldap      -- use LDAP (configuration is in /etc/saslauthd.conf)
#
# Only one option may be used at a time. See the saslauthd man page
# for more information.
#
# Example: MECHANISMS="pam"
MECHANISMS="pam"
# Additional options for this mechanism. (default: none)
# See the saslauthd man page for information about mech-specific options.
MECH_OPTIONS=""
# How many saslauthd processes should we run? (default: 5)
# A value of 0 will fork a new process for each connection.
THREADS=5
# Other options (default: -c)
# See the saslauthd man page for information about these options.
#
# Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"
# Note: See /usr/share/doc/sasl2-bin/README.Debian
OPTIONS="-c  -m /var/spool/postfix/var/run/saslauthd -</pre>
<p>Start then saslauthd:</p>
<p>/etc/init.d/saslauthd start</p>
<p>To see if SMTP-AUTH and TLS work properly now run the following command:</p>
<p>telnet yourdomain.com 25</p>
<p>After you have established the connection to your Postfix mail server type</p>
<p>ehlo yourdomain.com</p>
<p>The output should look something like:</p>
<p>250-yourdomain.com<br />
250-PIPELINING<br />
250-SIZE 10240000<br />
250-VRFY<br />
250-ETRN<br />
250-STARTTLS<br />
250-AUTH PLAIN LOGIN<br />
250-AUTH=PLAIN LOGIN<br />
250-ENHANCEDSTATUSCODES<br />
250-8BITMIME<br />
250 DSN</p>
<p>We have now Postfix running. If you add users (adduser command) Postfix will deliver then directly emails in users mail box located in the home folder.</p>
<h3>2. Installation of Dovecot</h3>
<p>Dovecot configuration is pretty straight forward (remember we will use only pop3 protocol to save memory):</p>
<p>apt-get install dovecot-common dovecot-pop3d</p>
<p>Open then dovecot conf situated in /etc/dovecot/. You have to add manually the protocol you want to use (pop3 pop3s</p>
<pre># Protocols we want to be serving: imap imaps pop3 pop3s
# If you only want to use dovecot-auth, you can set this to "none".
#protocols = imap imaps
protocols = pop3s pop3</pre>
<p>And uncomment the two following lines to tell Dovecot where to fint the certificate you have creted earlier</p>
<pre>ssl_cert_file = /etc/ssl/yourdomain/yourdomain.crt
ssl_key_file = /etc/ssl/yourdomain/yourdomain.key</pre>
<p>You have then to restart Dovecot</p>
<p>/etc/init.d/dovecot restart</p>
<p>and we have now a functionnal mail server.</p>
<h3>3. Installation of PHP5 (along with xcache)</h3>
<p>apt-get install php5-cli php5-cgi php5-mysql php5-xcache</p>
<p>Note that xcache has to be implemented manually by adding the following lines in the php.ini located in /etc/php5/cgi/ (please tune this config according to your system).</p>
<pre>[xcache-common]
extension = xcache.so
[xcache.admin]
xcache.admin.user = "mOo"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = ""
[xcache]
; ini only settings, all the values here is default unless explained
; select low level shm/allocator scheme implemenation
xcache.shm_scheme =        "mmap"
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size &gt; 0) and your system mmap allows
xcache.size  =                32M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count =                 1
; just a hash hints, you can always store count(items) &gt; slots
xcache.slots =                8K
; ttl of the cache item, 0=forever
xcache.ttl   =                 0
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval =           0
; same as aboves but for variable cache
xcache.var_size  =            32M
xcache.var_count =             1
xcache.var_slots =            8K
; default ttl
xcache.var_ttl   =             0
xcache.var_maxttl   =          0
xcache.var_gc_interval =     300
xcache.test =                Off
; N/A for /dev/zero
xcache.readonly_protection = Off
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection
; 2 group of php won't share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path
xcache.mmap_path =    "/dev/zero"
; leave it blank(disabled) or "/tmp/phpcore/"
; make sure it's writable by php (without checking open_basedir)
xcache.coredump_directory =   ""
; per request settings
xcache.cacher =               On
xcache.stat   =               On
xcache.optimizer =            On
[xcache.coverager]
; per request settings
; enable coverage data collecting for xcache.coveragedump_directory and xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)
xcache.coverager =          Off
; ini only settings
; make sure it's readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On
xcache.coveragedump_directory = ""</pre>
<p>Note: you have to adjust manually the xcache.size and xcache.var_size according to your server (it&#8217;s on 0 by default, meaning that xcache isn&#8217;t enabled at all). One other thing is the xcache.count variable. If you have a vps that takes advantage of 2 processors, you can put 2 instead of one.</p>
<p>You can do that right now even if your php configuration isn&#8217;t loaded yet so everything will be in good order when Nginx and fcgi process will be started.</p>
<h3>4. Installation of Mysql and PhpMyAdmin</h3>
<p>apt-get install mysql mysql-server</p>
<p>There is often a problem with mysql to setup the root password. So the best thing to do is first stopping mysql:</p>
<p>/etc/init.d/mysql stop</p>
<p>Then update the user table</p>
<p>mysqld &#8211;skip-grant-tables &#8211;skip-networking &amp;</p>
<p>mysql mysql</p>
<p>UPDATE user SET password=PASSWORD(&#8216;yourrootpassword&#8217;) WHERE User=&#8221;root&#8221; AND Host=&#8221;localhost&#8221;;</p>
<p>quit</p>
<p>/etc/init.d/mysql restart</p>
<h3>5. Installation of NGINX (Ubuntu only, see below for Debian users)</h3>
<p>The nginx version proposed by Feisty is a prehistoric one (not to mention drapper). Fortunately, there&#8217;s a place you can get the latest stable version, or if you are adventurous, the latest dev version.</p>
<p>Note for Debian users: I didn&#8217;t find a recent .deb package so you have either the choice to compile from sources or to do a apt-get install nginx to have a not so new version. For more informations about Nginx please go to the <a rel="nofollow" target="_blank" href="http://wiki.codemongers.com/" target="_blank">Nginx Wiki</a> website. You can find there the sources and a good doc about all the modules (ssl, auth_basic and so on).</p>
<p>wget http://technokracy.net/nginx/nginx_0.5.32~grrr-1_i386.deb</p>
<p>(Note that if you are running on AMD replace i386 by amd64.)</p>
<p>Then type:</p>
<p>dpkg -i nginx_0.5.32~grrr-1_i386.deb</p>
<p>Nginx is now up and running on default port 8000 (just in case you already have Apache or anything else on port 80).</p>
<p>The default root folder is Nginx-default and is located in /var/www/</p>
<p>To change that and to start to listen to the fast-cgi we will launch next, you have to open /etc/nginx/sites-available/default.</p>
<p>vi /etc/nginx/sites-available/default</p>
<p>You can find there all the obvious options to change and add (or uncomment the original php paragraph):</p>
<pre>        location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;
    }</pre>
<p>We&#8217;ve just asked Nginx to listen to fcgi on port 9000. So we have to start now the fcgi process. I&#8217;ve chosen to use spawn-fcgi and to make my own init script of it (so the process will start after reboot). To have spawn-fcgi you have to get lighttpd configured but without the need to install it. Let&#8217;s grab the latest version:</p>
<p>wget http://www.lighttpd.net/download/lighttpd-1.4.18.tar.bz2</p>
<p>tar -xvjf lighttpd-1.4.18.tar.bz2</p>
<p>cd lighttpd-1.4.18</p>
<p>./configure</p>
<p>make</p>
<p>cp src/spawn-fcgi /usr/bin/spawn-fcgi</p>
<p>Note that we did not type make install so lighttpd is not running!</p>
<p>Then we create a shell script we can call php-fastcgi or whatever you want and place that file in /usr/bin/ to make it simple (as php5-cgi and spawn-fcgi are already there&#8230;).</p>
<p>touch /usr/bin/php-fastcgi</p>
<p>Then edit it:</p>
<p>vi /usr/bin/php-fastcgi</p>
<p>and add the following:</p>
<pre>#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -f /usr/bin/php5-cgi</pre>
<p>That means every time this script will be called, fcgi will be spawned on port 9000 for user www-data (default user).</p>
<p>To make it work at startup we need now to create an init script:</p>
<p>touch /etc/init.d/init-fastcgi</p>
<p>Edit and add:</p>
<p>vi /etc/init.d/init-fastcgi</p>
<pre>#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case "$1" in
    start)
      $PHP_SCRIPT
      RETVAL=$?
  ;;
    stop)
      killall -9 php
      RETVAL=$?
  ;;
    restart)
      killall -9 php
      $PHP_SCRIPT
      RETVAL=$?
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL</pre>
<p>You may have to change the permissions there by typing:</p>
<p>chmod 755 /etc/init.d/init-fastcgi</p>
<p>Check then if it works by typing:</p>
<p>/etc/init.d/init-fastcgi start</p>
<p>You should have an answer from spawn-fcgi attributing a PID process. To make now everything working after reboot type:</p>
<p>update-rc.d init-fastcgi defaults</p>
<p>And we are done. To check if php is working as fast-cgi you can first type:</p>
<p>ps ax | grep php</p>
<p>To check then if Nginx is listening to php, create an echo command in an empty php file:</p>
<pre>&lt;? echo phpinfo(); ?&gt;</pre>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx directadmin">nginx directadmin</a> (7)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="lemp howto">lemp howto</a> (3)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="centos appliance vmware lamp optimize">centos appliance vmware lamp optimize</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="linux install lemp">linux install lemp</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx fcgi php $_REQUEST is empty">nginx fcgi php $_REQUEST is empty</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx installation on sles">nginx installation on sles</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx lamp windows">nginx lamp windows</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx postfix mysql pipe mail to php">nginx postfix mysql pipe mail to php</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="plesk change setting saslauthd">plesk change setting saslauthd</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="preinstalled lemp">preinstalled lemp</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux</title>
		<link>http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html</link>
		<comments>http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html#comments</comments>
		<pubDate>Mon, 19 Dec 2011 05:38:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1893</guid>
		<description><![CDATA[The instruction mentioned below only applies to Debian and Ubuntu Linux. I am going to document following things: =&#62; Install lighttpd =&#62; Prepare the file system for the jail =&#62; Run FastCGI PHP and MySQL from the jail =&#62; Add Perl support to the jail =&#62; Take care of sendmail =&#62; Run multiple domains (virtual [...]]]></description>
			<content:encoded><![CDATA[<p>The instruction mentioned below only applies to Debian and Ubuntu Linux. I am going to document following things:</p>
<p>=&gt; Install lighttpd<br />
=&gt; Prepare the file system for the jail<br />
=&gt; Run FastCGI PHP and MySQL from the jail<br />
=&gt; Add Perl support to the jail<br />
=&gt; Take care of sendmail<br />
=&gt; Run multiple domains (virtual hosting) from chrooted jail etc</p>
<p>Please note that information outlined below is for advanced UNIX users or admins only <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_wink.gif' alt="icon wink Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux" class='wp-smiley' title="Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux" /> .</p>
<p><strong>Note:</strong> If you are using Ubuntu Linux read this howto.</p>
<p>&nbsp;</p>
<h3>Step # 1: Install lighttpd, php4-cgi and mysql server</h3>
<p>Use apt-get command to install packages:<code># apt-get install lighttpd php4-cgi php4-cli php4-mysql mysql-server </code>Note: If you need other php modules just install them using apt-get command.</p>
<h3>Step # 2: Prepare the file system</h3>
<p>Create a directory called /webroot:<code># mkdir /webroot</code></p>
<p>Create temporary /webroot/tmp directory:<code># mkdir /webroot/tmp/<br />
# chmod 1777 /webroot/tmp/</code></p>
<p>Create /etc directory to store php.ini file:<code># mkdir /webroot/etc</code></p>
<p>Create a log directory for lighttpd web server:<code># mkdir -p /webroot/var/log/lighttpd<br />
# chown www-data:www-data /webroot/var/log/lighttpd</code></p>
<p>Create a cache directory:<code># mkdir -p /webroot/var/tmp/lighttpd/cache/compress/<br />
# chown www-data:www-data /webroot/var/tmp/lighttpd/cache/compress/</code></p>
<p>Create a lighttpd home directory for virtual hosting<br />
<code># mkdir -p /webroot/home/lighttpd<br />
# chown www-data:www-data /webroot/home/lighttpd<br />
# chmod 0700 /webroot/home/lighttpd<br />
# ls -dl /webroot/home/lighttpd<br />
</code>Output:</p>
<pre>drwx------  2 www-data www-data 4096 Oct  5 23:15 /webroot/home/lighttpd</pre>
<p>A handy shell script (l2chroot [download] ) to copy necessary shared system libraries:</p>
<pre>#!/bin/bash
BASE="/webroot"
if [ $# -eq 0 ]; then
  echo "Syntax : $0 /path/to/executable"
  echo "Example: $0 /usr/bin/php5-cgi"
  exit 1
fi
[ ! $BASE ] &amp;&amp; mkdir -p $BASE || :
# iggy ld-linux* file as it is not shared one
FILES="$(ldd $1 | awk '{ print $3 }' |egrep -v ^'\(')"
echo "Copying shared files/libs to $BASE..."
for i in $FILES
do
  d="$(dirname $i)"
  [ ! -d $BASE$d ] &amp;&amp; mkdir -p $BASE$d || :
  /bin/cp $i $BASE$d
done
# copy /lib/ld-linux* or /lib64/ld-linux* to $BASE/$sldlsubdir
# get ld-linux full file location
sldl="$(ldd $1 | grep 'ld-linux' | awk '{ print $1}')"
# now get sub-dir
sldlsubdir="$(dirname $sldl)"
if [ ! -f $BASE$sldl ];
then
  echo "Copying $sldl $BASE$sldlsubdir..."
  /bin/cp $sldl $BASE$sldlsubdir
else
  :
fi</pre>
<p>Put l2chroot in /bin directory and set executable permission:<code># wget http://www.cyberciti.biz/files/lighttpd/l2chroot.txt<br />
# mv l2chroot.txt l2chroot<br />
# cp l2chroot /bin<br />
# chmod +x /bin/l2chroot</code></p>
<h3>Step 3: Put PHP in the jail</h3>
<p>Now you need to copy PHP executable files and necessary extensions (php-mysql) to /webroot directory.<br />
<code># mkdir -p /webroot/usr/bin<br />
# cp /usr/bin/php4-cgi /webroot/usr/bin/<br />
# cp /usr/bin/php4 /webroot/usr/bin/</code><br />
Copy /etc/php4/cgi/php.ini file to /webroot/etc/ directory.<br />
<code># cd /webroot/etc/<br />
# cp -avr /etc/php4 .</code></p>
<p>Now copy other config files in jail:<br />
<code># cp /etc/hosts /webroot/etc/<br />
# cp /etc/nsswitch.conf /webroot/etc/<br />
# cp /etc/resolv.conf /webroot/etc/<br />
# cp /etc/services /webroot/etc/<br />
# cp /etc/localtime /webroot/etc/</code></p>
<p>Copy all php shared libraries used by /usr/bin/php4 and /usr/bin/php4-cgi using your l2chroot script:<br />
<code># /bin/l2chroot /usr/bin/php4<br />
# /bin/l2chroot /usr/bin/php4-cgi</code></p>
<p>Now you have all shared libraries in /webroot directory. You can verify this with ls command. There is one more file, which you need to copy manually &#8211; /lib/ld-linux.so.2:<br />
<code># cp /lib/ld-linux.so.2 /webroot/lib</code></p>
<h3>Step 4: Put php MySQL extension in the jail</h3>
<p>To access MySQL database server you need to use php4-mysql extension.<br />
Copy php mysql extension from /usr/lib/php4/20050606 directory, use following command to determine exact location of mysql.so file:<br />
<code># dpkg -L php4-mysql</code>Output:</p>
<pre>/.
/usr
/usr/lib
/usr/lib/php4
/usr/lib/php4/20050606
/usr/lib/php4/20050606/mysql.so
/usr/share
/usr/share/doc
/usr/share/doc/php4-mysql</pre>
<p>Copy /usr/lib/php4/20050606/mysql.so file to /webroot/usr/lib/php4/20050606/mysql.so and related shared libs using /bin/l2chroot script:<br />
<code># mkdir -p /webroot/usr/lib/php4/20050606<br />
# cp /usr/lib/php4/20050606/mysql.so /webroot/usr/lib/php4/20050606/<br />
# /bin/l2chroot /usr/lib/php4/20050606/mysql.so</code></p>
<p>Repeat above procedure to copy all your php shared modules such as php-imap (required for webmail), php-gd (GD module for php4 used by wordpress and other softwares), php-memcache etc.</p>
<h3>Step # 5: Configure lighttpd to run from chrooted jail</h3>
<p>Make sure fastcgi module is enabled:<br />
<code># lighty-enable-mod fastcgi</code>Output:</p>
<pre>Available modules: auth cgi cml fastcgi proxy simple-vhost ssi ssl trigger-b4-dl userdir
Already enabled modules:
Enabling fastcgi: ok
Run /etc/init.d/lighttpd force-reload to enable changes</pre>
<p>Configure lighttpd by editing /etc/lighttpd/lighttpd.conf file:<br />
<code># vi /etc/lighttpd/lighttpd.conf </code></p>
<p>The most importat part is server.chroot directive. Open config file:<br />
<code># vi /etc/lighttpd/lighttpd.conf</code><br />
Set server.chroot to /webroot:<br />
<code>server.chroot = "/webroot"</code></p>
<p>Above directive applies chroot() call to directory called /webroot. Once applied no one (except root user) can access file system outside /webroot directory.</p>
<p>Rest of the configuration directives is documented very well in file itself. Start your lighttpd:<br />
<code># /etc/init.d/lighttpd start</code></p>
<h3>Test jail setup</h3>
<p>Create two test php files in /webroot/home/lighttpd</p>
<ul>
<li>db.php : Test MySQL database connectivity, make sure you modify this file for correct MySQL server hostname, username and password.</li>
<li>test.php : Test php via phpinfo()</li>
</ul>
<p>Open a web browser and type url http://yourdomain.com/test.php and http://yourdomain.com/db.php.</p>
<p>Congratulations, if you are able to run both db.php and test.php w/o problem. Always refer to /var/log/message (outside /webroot directory) for troubleshooting purpose. If you see error message that read as follows (tail -f /var/log/message) :</p>
<pre>php5-cgi[7325]: segfault at 0000000000001e98 rip 00002ad2cf6bd101 rsp 00007fffdb3f1ed0 error 4</pre>
<p>To fix this problem, copy all shared libs from /lib and /usr/lib to /chroot (or <strong>/lib64</strong> &amp; <strong>/usr/lib</strong> if you are using <em>64 bit Linux</em>) directory. But please do NOT copy any executable files from /bin/ /usr/bin or /usr/sbin directory.<br />
<code># cp -avr /lib/* /webroot/lib/<br />
# cp -avr /usr/lib/* /webroot/usr/lib/</code><br />
Follow these instructions for more information.</p>
<h3>Size of the /webroot jail</h3>
<p>Here is size of webroot jail:<br />
<code># du -ch</code>Output:</p>
<pre>28K     ./var/www
104K    ./var/log/lighttpd
108K    ./var/log
4.0K    ./var/run
4.0K    ./var/tmp/lighttpd/cache/compress
8.0K    ./var/tmp/lighttpd/cache
12K     ./var/tmp/lighttpd
16K     ./var/tmp
160K    ./var
4.0K    ./tmp
5.9M    ./usr/bin
2.7M    ./usr/lib/i686/cmov
2.7M    ./usr/lib/i686
48K     ./usr/lib/php4/20050606
52K     ./usr/lib/php4
7.5M    ./usr/lib
14M     ./usr
1.7M    ./lib/tls
2.0M    ./lib
44K     ./etc/php4/cgi
48K     ./etc/php4
56K     ./etc
16K     ./home/lighttpd
20K     ./home
16M     .
<strong>16M total </strong></pre>
<p>As you see our jail only took 16MB disk space. I will address rest of the issues such as perl support and sendmail problem tomorrow <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux" class='wp-smiley' title="Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux" /> </p>
<p>Continue reading the rest of Lighttpd series articles.</p>
<p>Updated for accuracy.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="centos 5 php lighthttpd">centos 5 php lighthttpd</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="ubuntu install apache2 php5">ubuntu install apache2 php5</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="lighttpd php5 chroot jail ubuntu">lighttpd php5 chroot jail ubuntu</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="lighttpd php4-cgi uses 20%">lighttpd php4-cgi uses 20%</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="lighttpd php mysql debian">lighttpd php mysql debian</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="lighttpd mysql &amp; php">lighttpd mysql &amp; php</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="lighttpd chroot freebsd">lighttpd chroot freebsd</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="lighthttpd php debian">lighthttpd php debian</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="install lighttpd centos">install lighttpd centos</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="How to config lihghthttd php mod cgi on centos 5">How to config lihghthttd php mod cgi on centos 5</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Do I Run a Firewall Script As Soon As eth0 Interface Brings Up?</title>
		<link>http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html</link>
		<comments>http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html#comments</comments>
		<pubDate>Sun, 18 Dec 2011 06:26:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[etc network]]></category>
		<category><![CDATA[iptables firewall]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1832</guid>
		<description><![CDATA[I use ADSL at home via ISP modem. As soon as my eth0 comes up I would like to have my firewall script get executed and setup the iptables firewall rules for me. Earlier, I used to type the command /root/fs.dsl.start via the sudo command. However, while reading the man page of interfaces command I [...]]]></description>
			<content:encoded><![CDATA[<p>I use ADSL at home via ISP modem. As soon as my eth0 comes up I would like to have my firewall script get executed and setup the iptables firewall rules for me.</p>
<p>Earlier, I used to type the command /root/fs.dsl.start via the sudo command. However, while reading the man page of interfaces command I came across the <strong>post-up</strong> option which run command after bringing the interface up. Following step demonstrates the usage of post-up option:</p>
<div><img src="http://files.cyberciti.biz/cbzcache/3rdparty/ubuntu-logo.jpg" alt="ubuntu logo How Do I Run a Firewall Script As Soon As eth0 Interface Brings Up?" border="0" title="How Do I Run a Firewall Script As Soon As eth0 Interface Brings Up?" /></div>
<p>1) Copy your firewall shell script to /etc/network/if-up.d/ directory:<br />
<code># cp /root/fw.dsl.start /etc/network/if-up.d/</code></p>
<p>2) Open Debian / Ubuntu networking configuration file /etc/network/interfaces:<br />
<code># vi /etc/network/interfaces</code></p>
<p>3) Setup post-up option, append following line to eth0 configuration section:<br />
<code># post-up /etc/network/if-up.d/fw.dsl.start</code></p>
<p>Where,</p>
<ul>
<li><strong>post-up command</strong> : Run <em>command or shell script</em> after bringing the interface eth0 up.</li>
</ul>
<p>Here is my /etc/network/interfaces after modification:</p>
<pre>auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
name Ethernet LAN card
address 192.168.1.1
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.254
post-up /etc/network/if-up.d/fw.dsl.start</pre>
<p>4) Save and close the file. Restart networking service:<br />
<code># /etc/init.d/networking restart</code></p>
<p>5) Verify that iptables rules are loaded:<br />
<code># iptables -L -n -v</code></p>
<h2>Additional Options</h2>
<p>To run command before bringing the interface up, enter:<br />
<code>pre-up command<br />
pre-up /scripts/networking.accounting_on</code><br />
To run command before taking the interface down, enter:<br />
<code>pre-down command</code><br />
To run command or script after taking the interface down, enter:<br />
<code>post-down command<br />
post-down /path/to/script.sh</code></p>
<h2>Example: Setting Up Static Routing</h2>
<p>The up and down options can be used to set up Debian static routing as follows as soon as eth0 interface available or down:<br />
<code>up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.8.18.17<br />
down route del -net 10.0.0.0 netmask 255.0.0.0 gw 10.8.18.17</code></p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="bash script post interface is up">bash script post interface is up</a> (2)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="asterisk if-up d">asterisk if-up d</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="shell script to find cpu usage in redhat">shell script to find cpu usage in redhat</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="shell ile direcadmin pass">shell ile direcadmin pass</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="plesk firewall eth0">plesk firewall eth0</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="firewall script">firewall script</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="debian interface bash shell">debian interface bash shell</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="debian firewall script">debian firewall script</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="bash shell debian interfaces">bash shell debian interfaces</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="umask nginx directamin">umask nginx directamin</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Linux flush or remove all iptables rules</title>
		<link>http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html</link>
		<comments>http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html#comments</comments>
		<pubDate>Sun, 18 Dec 2011 06:25:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[enterprise linux]]></category>
		<category><![CDATA[Firewall]]></category>
		<category><![CDATA[gnu linux]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[stop]]></category>
		<category><![CDATA[ubuntu linux]]></category>
		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1830</guid>
		<description><![CDATA[Here is small script that does this. Debian or Ubuntu GNU/Linux does not comes with any SYS V init script (located in /etc/init.d directory) . You create a script as follows and use it to stop or flush the iptables rules. Please don&#8217;t type rules at command prompt. Use the script to speed up work. [...]]]></description>
			<content:encoded><![CDATA[<p>Here is small script that does this. Debian or Ubuntu GNU/Linux does not comes with any SYS V init script (located in /etc/init.d directory) .</p>
<p>You create a script as follows and use it to stop or flush the iptables rules.</p>
<p>Please don&#8217;t type rules at command prompt. Use the script to speed up work.</p>
<h3>Procedure for Debian / Ubuntu Linux</h3>
<p>A) Create /root/fw.stop /etc/init.d/fw.stop script using text editor such as vi:</p>
<pre>#!/bin/sh
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT</pre>
<p>(B) Make sure you can execute the script:<br />
<code># chmod +x /root/fw.stop</code></p>
<p>(C) You can run the script:<br />
<code># /root/fw.stop</code></p>
<h2>A note for RedHat and friends Linux user</h2>
<p>Please note that RedHat enterprise Linux (RHEL) and Fedora / Centos Linux comes with pre-installed script, which can be used to stop the firewall:<br />
<code>#/etc/init.d/iptables stop</code></p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="/root/fw stop: no such file or directory">/root/fw stop: no such file or directory</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="centos cpanel flush iptables">centos cpanel flush iptables</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="commandsysctl freebsd">commandsysctl freebsd</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="flush iptables cpanel">flush iptables cpanel</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="iptables rule is removed">iptables rule is removed</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="plesk flush iptables">plesk flush iptables</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How do I Apply Debian Linux Security update?</title>
		<link>http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html</link>
		<comments>http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html#comments</comments>
		<pubDate>Sun, 18 Dec 2011 06:07:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[gnome desktop]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[OPTION]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[Step]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1816</guid>
		<description><![CDATA[It is very easy to update Debian Linux over Internet so that you can get updated packages in stable distribution. This short article explains you how to keep up to date your Debian server/workstation along with small tips. Step # 1 Configure Debian to get updates You need to configure the package resource list, which [...]]]></description>
			<content:encoded><![CDATA[<p>It is very easy to update Debian Linux over Internet so that you can get updated packages in stable distribution. This short article explains you how to keep up to date your Debian server/workstation along with small tips.</p>
<h4>Step # 1 Configure Debian to get updates</h4>
<p>You need to configure the package resource list, which is used to locate archives of the package distribution system in use on the system. You need to edit file /etc/apt/sources.list. However Debian comes with different tools to save your life (pick any one of the following to configure your system)</p>
<p><strong><span style="text-decoration: underline;">Option I: </span></strong><br />
If you are using GUI (KDE/Gnome) use synaptic GUI package manager (/usr/sbin/synaptic) is the best choice for you. Synaptic is a frontend for the apt package managent system. Assuming that you are using Gnome Desktop &gt; Click on Application &gt; System Tools &gt; Synaptic Package Manage. It will ask you to authenticate, please supply root user password. Once Synaptic is on screen, select Properties &gt; Repositories. If you can not find URL http://security.debian.org/, then click on New button and add the information as follows:<br />
URL: http://security.debian.org/<br />
Distribution: testing/updates<br />
Section: main contrib</p>
<p>Where,<br />
<strong>URL</strong> can be cdrom, file, http, and ftp. This is the place where apt will search for updates and packages.</p>
<p><strong>Distribution</strong> specifies our distibution type for example it can be stable, unstable or testing.<br />
Stable distribution used on production system.<br />
Testing is like beta distribution, mostly after some time this moves to statble distribution,<br />
Unstable is under development distribution.</p>
<p><strong>Section</strong> specifies what component you would like to get. For example main component includes most of the packages, where contrib packages are contributed by users and so on.</p>
<p><a rel="nofollow" target="_blank" href="http://figs.cyberciti.biz/blogs/tips_tricks/synaptic-debian-package-manager-snapshot.png"><img src="http://figs.cyberciti.biz/blogs/tips_tricks/synaptic-debian-package-manager-snapshot.png" alt="synaptic debian package manager snapshot How do I Apply Debian Linux Security update?" width="399" height="399" title="How do I Apply Debian Linux Security update?" /></a></p>
<p><strong><span style="text-decoration: underline;">Option II: </span></strong><br />
If you are using command line then use apt-setup command. It is an interactive program that simplifies adding sources to apt&#8217;s sources.list. It knows about all the major debian mirrors and can help you select one. On remote debian server over ssh this tool will save you. Most admin uses this option to configure/reconfigure apt source list. Login as root and type command:<br />
<strong># apt-setup</strong><br />
Follow on screen instructions.</p>
<p>(A) Select http/ftp server to get updates:<br />
<a rel="nofollow" target="_blank" href="http://figs.cyberciti.biz/blogs/tips_tricks/apt-setup-1.png"><img src="http://figs.cyberciti.biz/blogs/tips_tricks/apt-setup-1.png" alt="apt setup 1 How do I Apply Debian Linux Security update?" width="399" height="399" title="How do I Apply Debian Linux Security update?" /></a></p>
<p>(B) Select nearest mirror country wise, this is essential for speedy download:<br />
<a rel="nofollow" target="_blank" href="http://figs.cyberciti.biz/blogs/tips_tricks/apt-setup-2.png"><img src="http://figs.cyberciti.biz/blogs/tips_tricks/apt-setup-2.png" alt="apt setup 2 How do I Apply Debian Linux Security update?" width="399" height="399" title="How do I Apply Debian Linux Security update?" /></a></p>
<p>(C) Setup proxy server, username and password. This is only required if you don&#8217;t have direct access to Internet else please press enter key:<br />
<a rel="nofollow" target="_blank" href="http://figs.cyberciti.biz/blogs/tips_tricks/apt-setup-3.png"><img src="http://figs.cyberciti.biz/blogs/tips_tricks/apt-setup-3.png" alt="apt setup 3 How do I Apply Debian Linux Security update?" width="399" height="399" title="How do I Apply Debian Linux Security update?" /></a></p>
<p>(D) Save the configuration and exit as you don&#8217;t have any more APT configuration required:<br />
<a rel="nofollow" target="_blank" href="http://figs.cyberciti.biz/blogs/tips_tricks/apt-setup-4.png"><img src="http://figs.cyberciti.biz/blogs/tips_tricks/apt-setup-4.png" alt="apt setup 4 How do I Apply Debian Linux Security update?" width="399" height="399" title="How do I Apply Debian Linux Security update?" /></a></p>
<p><strong><span style="text-decoration: underline;">Option III: Edit file /etc/apt/sources.list </span></strong><br />
This is the fastest way to specify list of Internet site to get updates. Login as root user and fire vi text editor:<br />
<strong># vi /etc/apt/sources.list</strong></p>
<p>Please add following lines to it:<br />
<em>deb http://ftp.iitm.ac.in/debian/ testing main<br />
deb http://security.debian.org/ testing/updates main contrib</em></p>
<p>Save the file and exit to command prompt. I&#8217;m using ftp.iitm.ac.in to get all packages. This is the nearest mirror for me. If not sure then I recommend to use apt-setup tool. This tool aware of mirror according to your country.</p>
<h4>Step # 2: Resynchronize the package index files</h4>
<p>It is important to this step. This enables to fetch information of updated packages. Type apt-get command as follows:<br />
<strong># apt-get update </strong></p>
<pre><em>Hit http://ftp.iitm.ac.in testing/main Packages Hit http://ftp.iitm.ac.in testing/main Release Hit http://security.debian.org testing/updates/main Packages Hit http://security.debian.org testing/updates/main Release Hit http://security.debian.org testing/updates/contrib Packages Hit http://security.debian.org testing/updates/contrib Release Reading Package Lists... Done </em></pre>
<h4>Step # 3: Upgrade the Debian</h4>
<p>You got list of updated package list, naturally next logical step is to upgrade system. Just type following command.<br />
<strong># apt-get upgrade</strong></p>
<pre><em>Building Dependency Tree... Done The following packages have been kept back: apache-common base-config bind9-ho... ..... 443 upgraded, 0 newly installed, 0 to remove and 374 not upgraded. Need to get 249MB of archives. After unpacking 39.8MB of additional disk space will be used. Do you want to continue? [Y/n]</em></pre>
<p>Hit enter key to get updates. Please note that this will take some time.</p>
<h3><span style="text-decoration: underline;">Optional information</span></h3>
<p>Following tips may give you more information.</p>
<p>Q. How do I find Debian package is upgradeable or not?<br />
A:<br />
You must have a command called apt-show-versions installed on system. First install it:<br />
<strong># apt-get install apt-show-versions</strong><br />
Next just type apt-show-versions command to get only list of upgradeable packages :<br />
<strong># apt-show-versions -u | less</strong><br />
Or better grep it:<br />
<strong># apt-show-versions -u | grep &#8220;apache&#8221; </strong></p>
<p>Q: How do I upgrade all packages in testing:<br />
A:<br />
Well, you can use above procedure or use apt-show-versions command as follows:<br />
<strong># apt-get install $(apt-show-versions -u -b | fgrep testing)</strong></p>
<p>Q: How do I upgrade specific packages<br />
Very easy just type package name, for example if you wish to upgrade apache-perl package then type:<br />
<strong># apt-get install apache-perl</strong><br />
This is useful if you just wish to upgrade single package and not entire system.</p>
<p>For more information:<br />
* Read man pages of apt-get(8), sources.lst(5)<br />
* Read <a rel="nofollow" target="_blank" href="http://www.debian.org/security/">official Debian security</a> information.<br />
* Subscribe <a rel="nofollow" target="_blank" href="http://lists.debian.org/debian-security-announce/">debian-security-announce mailing list</a>. This is the first place where the security team informs the users about security problems about Debian packages.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="configure-debian">configure-debian</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="gnome cpanel">gnome cpanel</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="asterisk 10 0 1 setup">asterisk 10 0 1 setup</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="synaptic debian option kde">synaptic debian option kde</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="shell script to general centos and linux system information">shell script to general centos and linux system information</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="shell script collect hardware info">shell script collect hardware info</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="script get system configuration linux">script get system configuration linux</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="linux security updates debian">linux security updates debian</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="directadmin yum check hangs">directadmin yum check hangs</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html" title="debian only install security updates">debian only install security updates</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/how-do-i-apply-debian-linux-security-update.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restore Debian Linux Grub boot loader</title>
		<link>http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html</link>
		<comments>http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html#comments</comments>
		<pubDate>Sat, 17 Dec 2011 16:38:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[grub boot loader]]></category>
		<category><![CDATA[Loader]]></category>
		<category><![CDATA[master boot record]]></category>
		<category><![CDATA[TV]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1785</guid>
		<description><![CDATA[Recently my hard disk went bad (some bad sectors developed), my boot.ini (Windows XP boot file) corrupted. I was using NT boot loader to load Linux. So I need to repair the Grub i.e. restore Grub in master boot record (MBR). Today is national holiday (I-DAY) and I wanna watch TV. Problem is neither I [...]]]></description>
			<content:encoded><![CDATA[<p>Recently my hard disk went bad (some bad sectors developed), my boot.ini (Windows XP boot file) corrupted. I was using NT boot loader to load Linux. So I need to repair the Grub i.e. restore Grub in master boot record (MBR).</p>
<p>Today is national holiday (I-DAY) and I wanna watch TV. Problem is neither I can boot to Linux nor using XP. So I just took my Debian GNU/Linux DVD and booting started when I had presented installation option (after networking dialog prompt) :<br />
1) Press ALT+F2 (or ALT+CTRL+F2) to get shell prompt<br />
2) Then get the partition tables for the devices using fdisk command:<br />
<code># fdisk -l </code></p>
<p>3)When you type fdisk -l, you should see your partition name: /dev/scsi/host0/bus0/target0/lun0/part1 (for IDE disk it display same device file in IDE directory)</p>
<p>4)Once you identified your device file, mount disk using mount command:<br />
<code># mkdir /mydisk<br />
# mount /dev/scsi/host0/bus0/target0/lun0/part1 /mydisk</code></p>
<p>5) Next use chroot command to start interactive shell with special root directory i.e. /mydisk will act as root directory.<br />
<code># chroot /mydisk</code></p>
<p>6)Use grub-install command to reinstall grub (SCSI disk):<br />
<code># grub-install /dev/sda</code></p>
<p>If you have IDE device following command :<br />
<code># grub-install /dev/hda</code></p>
<p>Again replace /dev/hda and /dev/sda with your actual device names.</p>
<p>7)Type exit and reboot the system. You should see your GRUB and Linux again.<br />
<code># exit </code></p>
<p>Other choice was to use Linux Live CD (e.g. Mepis) and do the above procedure. Well, I could have used the Mepis to watch TV but I had some data and emails in Tunderbird so I opted to restore the Grub; watched TV, took backup of emails and now I will put new 120 GiB hard disk tomorrow :</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="repair debian boot sector">repair debian boot sector</a> (3)</li><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="debian grub repair">debian grub repair</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="centos 5 5 restore bootloader after installing windows">centos 5 5 restore bootloader after installing windows</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="restore debian linux grub boot loader">restore debian linux grub boot loader</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="repair grub bootloader">repair grub bootloader</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="repair boot problems debian grub linux">repair boot problems debian grub linux</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="linux grub bootloader repair debian">linux grub bootloader repair debian</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="grub reparieren ipfire">grub reparieren ipfire</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="grub repair linux debian">grub repair linux debian</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html" title="grub network restore">grub network restore</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/restore-debian-linux-grub-boot-loader.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux : How to run a command when boots up?</title>
		<link>http://thegioinguonmo.com/os/linux/linux-how-to-run-a-command-when-boots-up.html</link>
		<comments>http://thegioinguonmo.com/os/linux/linux-how-to-run-a-command-when-boots-up.html#comments</comments>
		<pubDate>Sat, 17 Dec 2011 16:31:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[system]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1772</guid>
		<description><![CDATA[Other distribution provided the file called /etc/rc.local but Debian does not use rc.local to customize the boot process. You can use simple method as follows to customize it. (A) Execute command at system startup Let us assume you would like to run command called i) Create a script called mystartup.sh in /etc/init.d/ directory(login as root) [...]]]></description>
			<content:encoded><![CDATA[<p>Other distribution provided the file called /etc/rc.local but Debian does not use rc.local to customize the boot process. You can use simple method as follows to customize it.</p>
<p>(A) Execute command at system startup<br />
Let us assume you would like to run command called</p>
<p>i) Create a script called mystartup.sh in /etc/init.d/ directory(login as root)<br />
<strong># vi /etc/init.d/mystartup.sh</strong></p>
<p>ii) Add commands to this script one by one:<br />
<strong>#!/bin/bash<br />
echo &#8220;Setting up customized environment&#8230;&#8221;<br />
fortune<br />
</strong></p>
<p>iii) Setup executable permission on script:<br />
<strong># chmod +x /etc/init.d/mystartup.sh</strong></p>
<p>iv)Make sure this script get executed every time Debian Linux system boot up/comes up:<br />
<strong># update-rc.d mystartup.sh defaults 100</strong></p>
<p>Where,<br />
<strong>mystartup.sh</strong>: Your startup script name<br />
<strong>defaults</strong> : The argument &#8216;defaults&#8217; refers to the default runlevels, which are 2 through 5.<br />
<strong>100</strong> : Number 100 means script will get executed before any script containing number 101. Just run the command ls –l /etc/rc3.d/ and you will see all script soft linked to /etc/init.d with numbers.</p>
<p>Next time you reboot the system, you custom command or script will get executed via mystartup.sh. You can add more commands to this file or even call other shell/perl scripts from this file too.</p>
<p>(B) Execute shell script at system startup<br />
Open the file mystartup.sh in /etc/init.d/ directory<br />
<strong># vi /etc/init.d/ mystartup.sh</strong></p>
<p>Append your script path to the end as follows (suppose your script is /root/fw.start – script that starts firewall)</p>
<p><strong>/root/fw.start</strong></p>
<p>Save the file.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/linux-how-to-run-a-command-when-boots-up.html" title="centos custum command on boot">centos custum command on boot</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/linux-how-to-run-a-command-when-boots-up.html" title="how to run a command on boot up in linux">how to run a command on boot up in linux</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/linux-how-to-run-a-command-when-boots-up.html" title="linux : how to run a command when boots up?">linux : how to run a command when boots up?</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/linux-how-to-run-a-command-when-boots-up.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: thegioinguonmo.com @ 2012-02-07 10:55:27 -->
