<?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>Hack Admin &#187; Khaled</title>
	<atom:link href="http://www.hackadmin.com/category/khaled/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackadmin.com</link>
	<description></description>
	<lastBuildDate>Tue, 16 Mar 2010 21:31:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>OpenVPN Tutorial</title>
		<link>http://www.hackadmin.com/2010/02/17/openvpn-tutorial/</link>
		<comments>http://www.hackadmin.com/2010/02/17/openvpn-tutorial/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 00:42:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Khaled]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenVPN]]></category>
		<category><![CDATA[TCP/IP]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/?p=236</guid>
		<description><![CDATA[Openvpn is an open source software, allows us to create a Virtual Private Network.

1. Istalling openvpn

	install these packages openvpn openssh-server openssl:

	laptop:~$ sudo apt-get install openvpn openssh-server openssl
]]></description>
			<content:encoded><![CDATA[<p>Article by <a href="http://www.hackadmin.com/khaled/">Khaled</a></p>
<p>Openvpn is an open source software, allows us to create a Virtual Private Network.</p>
<p><span id="more-236"></span><br />
1. Installing openvpn</p>
<p>	install these packages openvpn openssh-server openssl:</p>
<p>	laptop:~$ sudo apt-get install openvpn openssh-server openssl</p>
<p>	Now the ssh server is installed we can control it and access to it from anywhere on the web using the IP and port 22.</p>
<p>	In reality 22 is for SSH The best port for OpenVPN (http://www.iana.org/assignments/port-numbers) is 1194.</p>
<p>	There is special web interfaces to can interact and configure openVPN through a browser like webmin, </p>
<p>	so we should install apache, php and mysql with this command:</p>
<p>	laptop:~$ sudo apt-get install apache2 mysql-server-5.0 libapache2-mod-php5 php5 php5-common php5-mysql</p>
<p>	To install webmin:</p>
<p>	laptop:~$ sudo apt-get install webmin</p>
<p>2. VPN configuration:</p>
<p>	The openvpn use Private Key Infrastructure (PKI):</p>
<p>		1. One Public key for server and Private keys for each client.</p>
<p>		2. It uses Certification for more security each Certification is valid for one couple (Server, Client)</p>
<p>	The authentication With OpenVPN is a bidirectional, means the sever identify the client before trusting on and client identify the server too.</p>
<p>	Key Generation:</p>
<p>	To generate a Key we can use scripts provided by OpenVPN</p>
<p>	We create openvpn/ in /home to manipulate and create keys there:</p>
<p>	laptop:~$ sudo cp /usr/share/doc/openvpn/examples/easy-rsa /home/openvpn/ -R</p>
<p>	All commands are in /home/openvpn/2.0/ file</p>
<p>	laptop:~$ cd /home/openvpn/2.0</p>
<p>	Edit vars file:	</p>
<p>	laptop:~$ sudo nano vars    &#8212;&#8212;&#8212;&#8212;&#8211;// (nano is a text editor you can use others: gedit, &#8230;)</p>
<p>		Setup these variables KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, and KEY_EMAIL</p>
<p>		EX:</p>
<p>			export KEY_COUNTRY=DZ</p>
<p>			export KEY_PROVINCE=ALGER</p>
<p>			export KEY_CITY=alger</p>
<p>			export KEY_ORG=alger</p>
<p>			export KEY_EMAIL=xxxxxxxxx@xxx.dz</p>
<p>		* We can find other variables like:</p>
<p>			 * KEY_SIZE by default set to 1024 in some countries there is limit that you</p>
<p>			     should respect for this KEY_SIZE you can&#8217;t go over the limitation.</p>
<p>			* CA_EXPIRE : In how many days your certification will expire?</p>
<p>	Save and close (in nano ctrl+x)</p>
<p>	To set these variables we run this:</p>
<p>	laptop:~$ . ./vars  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;     //first dot isn&#8217;t a mistake</p>
<p>	We should clean all existing certification we have to not have conflits (run this command):</p>
<p>	laptop:~$ sudo ./clean-all &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-// will delete /home/openvpn/2.0/keys</p>
<p>	If you do&#8217;nt have certification set before nothing will be done.</p>
<p>	Now we create our Certification and key with CA (master Certification Authority) with this command:</p>
<p>	laptop:~$ sudo ./build-ca</p>
<p>	The certification now are created in keys directory: ca.crt ca.key</p>
<p>	Generate a certification and key to the SERVER:</p>
<p>	laptop:~$ sudo ./build-key-server SERVER &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-  //we suppose that server&#8217;s named SERVER</p>
<p>	When common name is required type the name OS the server (here SERVER)</p>
<p>	Generate certification and key for client:</p>
<p>	laptop:~$ sudo ./build-key client1</p>
<p>	when common name is required type the name of the client (client1)</p>
<p>	this common name MUST be different if you have many clients.</p>
<p>	To protect your key with a password use ./build-key-pass instead of ./build-key</p>
<p>	NB: We were able to generate the client key on its own end to avoid transfer through the network</p>
<p>	Diffie Hellman parameters should be generated for the openvpn server: </p>
<p>	laptop:~$ sudo ./build-dh</p>
<p>	these parameters are copied in keys directory dh1024.pem</p>
<p>	So now all Certifications and keys are in /home/openvpn/2.0/keys directory:</p>
<p>		name 	 	Utile for					Role					Secret</p>
<p>		ca.crt 		servers and all clients 		root Certification CA 		no</p>
<p>		ca.key 		key signing the machine (both) 	root key CA 			yes</p>
<p>		dh1024.pem 	server	 				Diffie Hellman parameters	no</p>
<p>		SERVER.crt 	server					server certification 		no</p>
<p>		SERVER.key 	server		 			server key 			yes</p>
<p>		client1.crt 	Client1					Client1 certification 		no</p>
<p>		client1.key 	Client1					Client1 key 			yes</p>
<p>	We copy files to the client machines using a secured tunel</p>
<p>3. Creation of the file configuration for clients and server</p>
<p>	There is samples of this configuration in /usr/share/doc/openvpn/examples/sample-config-files/   client.conf and server.conf.gz</p>
<p>	1. Server configuration:</p>
<p>		We should gunzip the server.conf.gz</p>
<p>		laptop:~$ sudo gunzip server.conf.gz</p>
<p>		and then copy this file to /home/openvpn using:</p>
<p>		laptop:~$ sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf /etc/openvpn/</p>
<p>		Edit server.conf:</p>
<p>		laptop:~$ sudo nano /home/openvpn/server.conf</p>
<p>		this would create a VPN with virtual interface and listen to the connections in 1194 port and distribute</p>
<p>		virtual addresses to clients that connect through 10.8.0.0/24</p>
<p>		By default this server.conf is useful but we can set more parameters(directives) like (IP, PORT, KEY_SIZE etc&#8230;)</p>
<p>		Client configuration and server one must be coherent.</p>
<p>	1. Client configuration:</p>
<p>		Edit the client.conf:</p>
<p>		laptop:~$ sudo nano /home/openvpn/client.conf</p>
<p>		Verify the name of certification and key of each client:</p>
<p>		ca ca.crt</p>
<p>		cert client.crt</p>
<p>		key client.key </p>
<p>		Go to the remote parameter and set up the server IP</p>
<p>		remote my-server-1 1194</p>
<p>		save the file</p>
<p>		Now we verify if client parameters if they correspond to the server one:</p>
<p>		dev (tun ou tap)</p>
<p>		proto (udp ou tcp)</p>
<p>		comp-lzo</p>
<p>		fragment</p>
<p>4. Starting the VPN:</p>
<p>	4.1. Before we start we should copy all file in keys directory and .conf to /etc/openvpn:</p>
<p>		4.1.1 SERVER:</p>
<p>			laptop:~$ sudo cp /home/openvpn/keys/SERVER.crt /etc/openvpn</p>
<p>			laptop:~$ sudo cp /home/openvpn/keys/SERVER.key /etc/openvpn</p>
<p>			laptop:~$ sudo cp /home/openvpn/keys/dh1024.pem /etc/openvpn</p>
<p>			laptop:~$ sudo cp /home/openvpn/server.conf /etc/openvpn</p>
<p>			laptop:~$ sudo cp /home/openvpn/keys/ca.crt /etc/openvpn</p>
<p>		4.1.2 Client:</p>
<p>			laptop:~$ sudo cp /home/openvpn/keys/client1.crt /etc/openvpn</p>
<p>			laptop:~$ sudo cp /home/openvpn/keys/client1.key /etc/openvpn</p>
<p>			laptop:~$ sudo cp /home/openvpn/keys/ca.crt /etc/openvpn</p>
<p>			laptop:~$ sudo cp /home/openvpn/client1.conf /etc/openvpn</p>
<p>	4.2 Start the server:</p>
<p>		laptop:~$ cd /etc/openvpn</p>
<p>		laptop:/etc/openvpn$ sudo openvpn server.conf</p>
<p>	4.3 Start the client1:</p>
<p>		aptop:~$ cd /etc/openvpn</p>
<p>		laptop:/etc/openvpn$ sudo openvpn client1.conf</p>
<p>	4.4 Test the VPN:</p>
<p>		From the client terminal try to ping the server which has the 10.8.0.1 by default:</p>
<p>		ping 10.8.0.1</p>
<p>To can communicate with other client through the network with the VPN you have to uncomment the client-to-client parameter in server.conf<br />
 and then you would be able to ping the other clients.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2010/02/17/openvpn-tutorial/feed/</wfw:commentRss>
		<slash:comments>48</slash:comments>
		</item>
		<item>
		<title>Amazon S3 backup Tutorial -via Khaled</title>
		<link>http://www.hackadmin.com/2010/02/12/amazon-s3-backup-tutorial-via-khaled/</link>
		<comments>http://www.hackadmin.com/2010/02/12/amazon-s3-backup-tutorial-via-khaled/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 22:54:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Amazon]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Khaled]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[S3]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/?p=198</guid>
		<description><![CDATA[To interact with amazon S3, we have many languages we can use as well as python. I chose python because it's a scripting language.  That means we don't need to compile and we don't need a virtual machine to run it, only an interpreter is needed.]]></description>
			<content:encoded><![CDATA[<p>Article by <a href="http://www.hackadmin.com/khaled/">Khaled</a></p>
<p>To interact with amazon S3, we have many languages we can use as well as python.  I chose python because it&#8217;s a scripting language.  That means we don&#8217;t need to compile and we don&#8217;t need a virtual machine to run it, only an interpreter is needed.</p>
<p>	There is some ready tools to interact with amazon S3 I found S3cmd it&#8217;s made with python and there is many methods within.</p>
<p><span id="more-198"></span><br />
Installing S3cmd   (nb: commands are in red color)</p>
<p>Its better to be root to have all permissions   Laptop:~$ sudo -i</p>
<p>Take the zip file and copy it somewhere for example /home/Your_Directory/  </p>
<p>1.To copy  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;     Laptop:~# cp s3cmd-0.9.9.91 /home/Your_Directory</p>
<p>2. Decompress the file.	&#8212;&#8212;&#8212;&#8212;&#8212;-  Laptop:~# unzip s3cmd.zip</p>
<p>3. Move to s3cmd folder	.&#8212;&#8212;&#8212;&#8212;&#8212;	Laptop:~# cd s3cmd-0.9.9.91</p>
<p>4. Change setup.py mod to can execute it.    Laptop:~/s3cmd-0.9.9.91# chmod +x setup.py </p>
<p>5. Run the setup file with this command.      Laptop:~/s3cmd-0.9.9.91# ./setup.py                                  </p>
<p>6. During the installation enter your 	access key and secret one, and choose secured connection.</p>
<p>	Now s3cmd is installed and your connection with s3 account is set, so you can transfer files to and from s3 account there is many commands you can use to can use them you should be in s3cmd folder, I verified most of the code and it uses methods provided by amazon s3 developers.</p>
<p>	The command that allows you to transfer from your server (linux) to amazon s3 is :</p>
<p>s3cmd-0.9.9.91#./s3cmd put Local_File s3://BUCKET_Name/Other_Files_In_Bucket</p>
<p>But this command will transfer “Local_File” to the bucket so if we have another new file within and we use the same command, the whole “Local_File” would be transferred too, so we loose in data transfer.</p>
<p>	BUT if we use a sync command we can synchronize a local file with a remote one, it means that if we have a local folder and we add files in it step by step this command allows us to transfer only missing files to the remote file,  this is how we minimize data transfer, so for example everyday we have a new tar.gz file added to our local file and our backup would be done everyday, </p>
<p>The command is :<br />
3cmd-0.9.9.91# ./s3cmd sync /home/Your_Directory/local_file/  s3://BUCKET_Name/Remote_File</p>
<p>Every time we run this command it copies only missing files.</p>
<p>Automation of our transfer with sync command:</p>
<p>	In linux OS we can automate execution of commands by adding them to a special file which has a specific (easy) syntax.<br />
To access to this file we use this command  &#8212;&#8212;&#8212;   3cmd-0.9.9.91# crontab -e</p>
<p>Our file is open now, we can insert any command to be executed at any time or day or month.</p>
<p>A sample line is so &#8212;&#8212;&#8212;&#8212;&#8212;-   * * * * * Command_to_execute</p>
<p>if we want to run any linux command for example at 3:59 PM we edit our line as follow<br />
59 15 * * *  Command_to_run</p>
<p>	Suppose that we have our tar.gz files already in a Local_File and we want to transfer them to the Remote_File with sync command everyday at 3:00 am, the line would be:</p>
<p>0 3 * * * Path_Where_s3cmd_Folder_is/./s3cmd  sync  /home/Your-Directory/Local_File/ s3://BUCKET/Remote_File/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2010/02/12/amazon-s3-backup-tutorial-via-khaled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding IP Addresses to Ubuntu -via Khaled</title>
		<link>http://www.hackadmin.com/2010/02/12/adding-ip-addresses-to-ubuntu-via-medi/</link>
		<comments>http://www.hackadmin.com/2010/02/12/adding-ip-addresses-to-ubuntu-via-medi/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 17:36:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Khaled]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[TCP/IP]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[Virtual_Interface]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/?p=191</guid>
		<description><![CDATA[1. Setup More than one IP address for one network interface:

The file which contains descriptions of the network interfaces on Ubuntu or debian is /etc/nework/interfaces
A network interface (material) by default is referenced by eth0 so if you have more than one it would be eth1 eth2, ]]></description>
			<content:encoded><![CDATA[<p>Article by <a href="http://www.hackadmin.com/khaled/">Khaled</a></p>
<p>1. Setup More than one IP address for one network interface:</p>
<p>The file which contains descriptions of the network interfaces on Ubuntu or debian is /etc/nework/interfaces<br />
A network interface (material) by default is referenced by eth0 so if you have more than one it would be eth1 eth2,<br />
etc&#8230; so to setup a virtual ip we should create a virtual network interface, the name of this one would be as follows<br />
eth0:1, eth0:2 etc&#8230; to create this interface we should add some lines to the<br />
/etc/network/interfaces file to discribe this interface</p>
<p><span id="more-191"></span></p>
<p>NB: modifying this file need the superuser privilages</p>
<p>laptop:/$ sudo nano /etc/network/interfaces</p>
<p>We add this lines</p>
<p>auto eth0:1  //&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-we have one eth0 and we add another virtual interface refered by :1<br />
iface eth0:1 inet static //&#8212;&#8212;-this interface would use a static IP We can use dhcp as well<br />
address 192.168.1.34   //&#8212;&#8212;&#8212; IP we want to assign<br />
netmask 255.255.255.0  //&#8212;&#8212;&#8212; The netmask IP<br />
broadcast 192.168.1.255 //&#8212;&#8212;&#8211; Broadcast IP<br />
gateway 192.168.1.1     //&#8212;&#8212;&#8211; Gateway (router or&#8230;)</p>
<p>Save the file</p>
<p>As you can see this is a simple text file, so right now the network interface isn&#8217;t set yet because this<br />
configuration isn&#8217;t applied</p>
<p>To set it we should restart our network interface by using this command with superuser privilages:</p>
<p>laptop:/$ sudo /etc/init.d/networking restart</p>
<p>Your interface is set</p>
<p>To verify if it works you can ping the address you assigned by useing this command</p>
<p>laptop:/$ ping [IP_you_assigned]</p>
<p>_______________________________________________________________________________________</p>
<p>2. There is a second method we can use is not permanent which means if you restart your machine or your interface<br />
it would be deleted.</p>
<p>To do it we have to use the binary file /sbin/ip</p>
<p>To add a virtual IP we use this command:</p>
<p>laptop:/$ sudo /sbin/ip addr add [IP_you_want_to_add]/24 dev eth0</p>
<p>Here we don&#8217;t need to restart our network interface cause it&#8217;s not a simple file it a binary file it&#8217;s applied by<br />
this command.</p>
<p>To check that your change works you can ping the new address using this command:</p>
<p>laptop:/$ sudo ping [IP_address_you_added]</p>
<p>You can also verify the new IP has been added by using the ifconfig command as shown below:</p>
<p>laptop:/$ ifconfig eth0:1<br />
eth0:1    Link encap:Ethernet  HWaddr 00:26:b9:11:34:16<br />
          inet addr:192.168.3.22  Bcast:192.168.3.255  Mask:255.255.255.0<br />
          UP BROADCAST MULTICAST  MTU:1500  Metric:1<br />
          Interrupt:19 Base address:0xa000 </p>
<p>This will show you that the address you assigned is actually on the correct interface.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2010/02/12/adding-ip-addresses-to-ubuntu-via-medi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

