<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Werk</title>
	
	<link>http://werk.feub.net</link>
	<description>^.^</description>
	<lastBuildDate>Tue, 21 Feb 2012 15:50:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/feub/werk" /><feedburner:info uri="feub/werk" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Mise en place d’un serveur FTP vsftpd</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/iG1HiKq4RtA/</link>
		<comments>http://werk.feub.net/2012/02/mise-en-place-dun-serveur-ftp-vsftpd/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 15:24:45 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[vsftpd]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=920</guid>
		<description><![CDATA[Petit billet rapide expliquant l&#8217;installation d&#8217;un serveur FTP vsftpd sous Fedora 15. Longtemps utilisateur de ProFTPd, j&#8217;ai décidé de switcher pour essayer (ayant des besoins très réduits niveau FTP), comme pour ce dernier, en 5 minutes vsftpd était fonctionnel. L&#8217;installation se fait avec yum : # yum install vsftpd Ensuite, on passe à une rapide [...]]]></description>
			<content:encoded><![CDATA[<p>
Petit billet rapide expliquant l&#8217;installation d&#8217;un serveur FTP <a href="https://security.appspot.com/vsftpd.html" title="vsftpd" target="_blank">vsftpd</a> sous <a href="http://www.fedora-fr.org/" title="fedora-fr.org" target="_blank">Fedora</a> 15. Longtemps utilisateur de <a href="http://www.proftpd.org/" title="proftpd" target="_blank">ProFTPd</a>, j&#8217;ai décidé de switcher pour essayer (ayant des besoins très réduits niveau FTP), comme pour ce dernier, en 5 minutes vsftpd était fonctionnel.
</p>
<p>
L&#8217;installation se fait avec <code>yum</code> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install vsftpd</span></pre></div></div>

<p>
Ensuite, on passe à une rapide étape de configuration basique du fichier <code>/etc/vsftpd/vsftpd.conf</code>, dont voici ce que j&#8217;ai modifié :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ligne 12: no anonymous</span>
<span style="color: #007800;">anonymous_enable</span>=NO
&nbsp;
<span style="color: #666666; font-style: italic;"># line 82,83: décommenter</span>
<span style="color: #007800;">ascii_upload_enable</span>=YES
<span style="color: #007800;">ascii_download_enable</span>=YES
&nbsp;
<span style="color: #666666; font-style: italic;"># line 97, 98: décommenter</span>
<span style="color: #666666; font-style: italic;"># les utilisateurs seront ainsi chrootés dans leur home</span>
<span style="color: #007800;">chroot_local_user</span>=YES
<span style="color: #007800;">chroot_list_enable</span>=YES
&nbsp;
<span style="color: #666666; font-style: italic;"># line 100: décommenter</span>
<span style="color: #666666; font-style: italic;"># les utilisateurs listés dans ce fichier pourront aller au delà du chroot</span>
<span style="color: #007800;">chroot_list_file</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd<span style="color: #000000; font-weight: bold;">/</span>chroot_list
&nbsp;
<span style="color: #666666; font-style: italic;"># line 106: décommenter</span>
<span style="color: #007800;">ls_recurse_enable</span>=YES
&nbsp;
<span style="color: #666666; font-style: italic;"># use localtime</span>
<span style="color: #007800;">use_localtime</span>=YES</pre></div></div>

<p>
On ajoute les utilisateurs qui peuvent aller hors de leur home dans le fichier <code>/etc/vsftpd/chroot_list</code>. On (re)démarre le serveur et éventuellement on dit au système de le démarrer avec la machine :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># systemctl start vsftpdservice</span>
<span style="color: #666666; font-style: italic;"># systemctl enable vsftpdservice</span></pre></div></div>

<p>
C&#8217;est tout.</p>
<img src="http://feeds.feedburner.com/~r/feub/werk/~4/iG1HiKq4RtA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2012/02/mise-en-place-dun-serveur-ftp-vsftpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2012/02/mise-en-place-dun-serveur-ftp-vsftpd/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mise-en-place-dun-serveur-ftp-vsftpd</feedburner:origLink></item>
		<item>
		<title>Mise en place d’un serveur VNC et tunnel SSH</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/P2NJkOjHEZE/</link>
		<comments>http://werk.feub.net/2011/12/mise-en-place-dun-serveur-vnc-et-tunnel-ssh/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 14:08:23 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[putty]]></category>
		<category><![CDATA[remote access]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tigervnc]]></category>
		<category><![CDATA[vnc]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=900</guid>
		<description><![CDATA[Voici un court tutoriel pour utiliser VNC sur une machine CentOS et ainsi accéder à une (ou des) session(s) X. En ce qui me concerne, je l&#8217;utilise ponctuellement pour avoir accès au bureau XFCE de mon serveur dédié. Installation du paquet L&#8217;installation se fait toujours avec yum, pour CentOS 5.x et Fedora avant F11: # [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/12/Network_Connections.png" alt="" class="floatleft" />Voici un court tutoriel pour utiliser <a href="http://fr.wikipedia.org/wiki/Virtual_Network_Computing" title="Wikipedia : VNC" target="_blank">VNC</a> sur une machine <a href="http://www.centos.org/" title="CentOS" target="_blank">CentOS</a> et ainsi accéder à une (ou des) session(s) X. En ce qui me concerne, je l&#8217;utilise ponctuellement pour avoir accès au bureau <a href="http://www.xfce.org/" title="XFCE" target="_blank">XFCE</a> de mon serveur dédié.
</p>
<p><span id="more-900"></span></p>
<h4>
Installation du paquet<br />
</h4>
<p>
L&#8217;installation se fait toujours avec <code>yum</code>, pour CentOS 5.x et <a href="http://fedoraproject.org/" title="Fedora Project" target="_blank">Fedora</a> avant F11:
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install vnc-server</span></pre></div></div>

<p>
Pour CentOS 6.x et Fedora après F11, on utilise TigerVNC :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install tigervnc-server</span></pre></div></div>

<h4>
Attribuer un mot de passe VNC à l&#8217;utilisateur<br />
</h4>
<p>
Se connecter en tant que l&#8217;utilisateur pour l&#8217;accès VNC, puis lui attribuer un mot de passe avec cette commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">vncpasswd</pre></div></div>

<p>
Ceci va créer le répertoire <code>.vnc</code> et stocker le mot de passe.
</p>
<h4>
Configurer le serveur<br />
</h4>
<p>
Il faut éditer le fichier <code>/etc/sysconfig/vncservers</code> avec quelque chose comme ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">VNCSERVERS</span>=<span style="color: #ff0000;">&quot;2:fabien toto:6&quot;</span>
VNCSERVERARGS<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;-geometry 1024x768 -localhost&quot;</span>
VNCSERVERARGS<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;-geometry 800x600&quot;</span></pre></div></div>

<p>
Ce qui signifie que fabien va avoir un écran de 1024x768px accessible sur le port VNC 2 (port VNC 5900 + 2 = 5902) seulement en local, alors que toto utilisera le port 6 avec une résolution de 800x600px.
</p>
<h4>
Démarrage et initialisation du serveur<br />
</h4>
<p>
Le serveur doit etre lancé une fois pour initialiser le fichier de configuration <code>~/.vnc/xstartup</code> des utilisateurs :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /sbin/service vncserver start</span>
<span style="color: #666666; font-style: italic;"># /sbin/service vncserver stop</span></pre></div></div>

<p>
Il ne reste plus que quelques modifications à effectuer pour accéder à sa session à distance. Dans le cas de XFCE, je remplace simplement <code>twm &#038;</code> par <code>startxfce4 &#038;</code> (<code>gnome-session &#038;</code> pour Gnome ou <code>startkde &#038;</code> pour KDE). La ligne <code>XKL_XMODMAP_DISABLE=1</code> est nécessaire pour éviter des problèmes de mappage de clavier, il est bon de ne pas l&#8217;oublier. Voici mon fichier <code>xstartup</code> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Uncomment the following two lines for normal desktop:</span>
<span style="color: #666666; font-style: italic;">#unset SESSION_MANAGER</span>
<span style="color: #666666; font-style: italic;">#exec /etc/X11/xinit/xinitrc</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vnc<span style="color: #000000; font-weight: bold;">/</span>xstartup <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vnc<span style="color: #000000; font-weight: bold;">/</span>xstartup
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.Xresources <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> xrdb <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.Xresources
xsetroot <span style="color: #660033;">-solid</span> grey
vncconfig <span style="color: #660033;">-iconic</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
xterm <span style="color: #660033;">-geometry</span> 80x24+<span style="color: #000000;">10</span>+<span style="color: #000000;">10</span> <span style="color: #660033;">-ls</span> <span style="color: #660033;">-title</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$VNCDESKTOP</span> Desktop&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #666666; font-style: italic;">#twm &amp;</span>
startxfce4 <span style="color: #000000; font-weight: bold;">&amp;</span></pre></div></div>

<h4>
Tunnel SSH<br />
</h4>
<p>
L&#8217;option <code>-localhost</code> n&#8217;autorise l&#8217;accès qu&#8217;en local. Pour accèder à ce serveur en VNC il faut donc au préalable établir une connexion SSH entre la machine cliente et celui-ci en créant un tunnel qui redirigera le port 5904 du serveur vers le port &#8211; par exemple &#8211; 6004 du client. Voici comment instancier cette connexion SSH depuis un client linux :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">6002</span>:localhost:<span style="color: #000000;">5902</span> IP_SERVEUR</pre></div></div>

<p>
Et voici la configuration de ce tunnel avec <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" title="puTTY" target="_blank">puTTY</a> sous Windows :
</p>
<div class="post-image">
<img src="http://werk.feub.net/medias/2011/12/1_tunnel_putty.png" alt="" title="puTTY" width="456" height="442" class="alignnone size-full wp-image-901" />
</div>
<div class="post-image">
<img src="http://werk.feub.net/medias/2011/12/2_tunnel_putty.png" alt="" title="Tunnel avec puTTY" width="456" height="442" class="alignnone size-full wp-image-903" />
</div>
<p>
Une fois la connexion effectuée, il suffit d&#8217;utiliser son client VNC avec localhost et le port 6004 pour accéder au serveur en toute sécurité. En ligne de commande sous linux avec le client vncviewer :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ vncviewer localhost:<span style="color: #000000;">6002</span></pre></div></div>

<p>
Et sous Windows par exemple avec le client UltraVNC :
</p>
<div class="post-image">
<img src="http://werk.feub.net/medias/2011/12/3_ultravnc.png" alt="" title="UltraVNC" width="375" height="372" class="alignnone size-full wp-image-904" />
</div>
<p>
De cette façon, il n&#8217;est pas possible de se connecter à la machine depuis une autre IP que la locale (<code>127.0.0.1</code>).</p>
<img src="http://feeds.feedburner.com/~r/feub/werk/~4/P2NJkOjHEZE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/12/mise-en-place-dun-serveur-vnc-et-tunnel-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2011/12/mise-en-place-dun-serveur-vnc-et-tunnel-ssh/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mise-en-place-dun-serveur-vnc-et-tunnel-ssh</feedburner:origLink></item>
		<item>
		<title>Triste jour</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/mivcWYSpG8I/</link>
		<comments>http://werk.feub.net/2011/10/triste-jour/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 07:17:51 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[général]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[au revoir]]></category>
		<category><![CDATA[steve jobs]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=891</guid>
		<description><![CDATA[On a beau se dire que cela ne nous concerne pour ainsi dire pas, qu&#8217;il s&#8217;agit de sphères hors de portée, très éloignées, mais ça fait quand même un sacré quelque chose à l&#8217;intérieur, un peu mal aux tripes, un gros pincement au cœur. Steve Jobs a passé le relais.. pour de bon.Au revoir iPapy.]]></description>
			<content:encoded><![CDATA[<p><img src="http://werk.feub.net/medias/2011/10/black_apple64.png" alt="" class="floatleft" />On a beau se dire que cela ne nous concerne pour ainsi dire pas, qu&#8217;il s&#8217;agit de sphères hors de portée, très éloignées, mais ça fait quand même un sacré quelque chose à l&#8217;intérieur, un peu mal aux tripes, un gros pincement au cœur. Steve Jobs a passé le relais.. pour de bon.<br /><a href="http://www.apple.com/stevejobs/" title="http://www.apple.com/stevejobs/" target="_blank">Au revoir iPapy</a>.</p>
<img src="http://feeds.feedburner.com/~r/feub/werk/~4/mivcWYSpG8I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/10/triste-jour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2011/10/triste-jour/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=triste-jour</feedburner:origLink></item>
		<item>
		<title>Stockage : réplication en temps réel avec DRBD</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/ZHE3n3ORdUg/</link>
		<comments>http://werk.feub.net/2011/09/drbd-centos-6/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 09:24:40 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[drbd]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[storage]]></category>
		<category><![CDATA[synchronisation]]></category>
		<category><![CDATA[système de fichiers]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=879</guid>
		<description><![CDATA[DRBD (Distributed Replicated Block Device) est une architecture de stockage distribuée pour GNU/Linux, pour parler rapidement on peut dire qu&#8217;il s&#8217;agit d&#8217;une sorte de RAID 1 au niveau du réseau. Cela permet d&#8217;avoir deux machines avec réplication de données de l&#8217;une vers l&#8217;autre, l&#8217;une étant désignée primaire et l&#8217;autre secondaire (mais il existe un mode [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/09/drbd_logo_small.gif" alt="" class="floatleft" /><a href="http://fr.wikipedia.org/wiki/DRBD" title="Wikipedia: DRBD" target="_blank">DRBD</a> (Distributed Replicated Block Device) est une architecture de stockage distribuée pour GNU/Linux, pour parler rapidement on peut dire qu&#8217;il s&#8217;agit d&#8217;une sorte de RAID 1 au niveau du réseau. Cela permet d&#8217;avoir deux machines avec réplication de données de l&#8217;une vers l&#8217;autre, l&#8217;une étant désignée primaire et l&#8217;autre secondaire (mais il existe un mode primaire/primaire également). Il s&#8217;agit d&#8217;un logiciel libre développé par la société <a href="http://www.linbit.com/" title="linbit.com" target="_blank">Linbit</a> qui par ailleurs offre un service de support.
</p>
<p>
DRBD réplique au niveau des périphériques de bloc, pour plus d&#8217;informations sur son fonctionnement, je vous renvoie à la <a href="http://fr.wikipedia.org/wiki/DRBD#Principe_de_fonctionnement" title="Wikipedia : DRBD" target="_blank">page Wikipedia de DRBD</a>.
</p>
<p><span id="more-879"></span></p>
<h4>Pré-requis</h4>
<p>
Ce tutoriel est réalisé avec deux machines sous <a href="http://www.centos.org/" title="centos.org" target="_blank">CentOS 6</a>, celles-ci sont respectivement nommées <code>centos-ha1</code> (IP : 192.168.1.10) et <code>centos-ha2</code> (IP : 192.168.1.11), le terme de nœud sera utilisé pour les désigner.<br />
SELinux est désactivé et le port 7789 ouvert au niveau du firewall.
</p>
<p>
DRBD fonctionnant au niveau bloc, il faut un disque ou une partition dédiée à cela. Dans l&#8217;exemple de ce billet, on part d&#8217;un groupe de volumes LVM nommé <code>vg_storage</code> avec un unique volume logique <code>lv_storage</code> qui est libre pour créer notre ressource DRBD. Un volume logique étant un périphérique de bloc aux yeux de Linux, cela convient parfaitement. Celui-ci n&#8217;a pas besoin (et ne doit pas) d&#8217;être formatté.
</p>
<h4>Installation</h4>
<p>
Depuis CentOS 6, les paquets DRBD ne sont plus dans les dépots de base, il faut donc ajouter ceux de <a href="http://atrpms.net/" title="atRPMS" target="_blank">atRPMS</a>. Pour ce faire, ajouter le fichier <code>atrpms.repo</code> sous <code>/etc/yum.repos.d</code> contenant ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>atrpms<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #007800;">name</span>=CentOS <span style="color: #007800;">$releasever</span> - <span style="color: #007800;">$basearch</span> - ATrpms
<span style="color: #007800;">baseurl</span>=http:<span style="color: #000000; font-weight: bold;">//</span>dl.atrpms.net<span style="color: #000000; font-weight: bold;">/</span>el<span style="color: #007800;">$releasever</span>-<span style="color: #007800;">$basearch</span><span style="color: #000000; font-weight: bold;">/</span>atrpms<span style="color: #000000; font-weight: bold;">/</span>stable
<span style="color: #007800;">gpgkey</span>=http:<span style="color: #000000; font-weight: bold;">//</span>atrpms.net<span style="color: #000000; font-weight: bold;">/</span>RPM-GPG-KEY.atrpms
<span style="color: #007800;">gpgcheck</span>=<span style="color: #000000;">1</span></pre></div></div>

<p>
Vérification de la présence de paquets relatifs à DRBD :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum search drbd</span>
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
<span style="color: #000000; font-weight: bold;">*</span> base: ftp.plusline.de
<span style="color: #000000; font-weight: bold;">*</span> extras: ftp.plusline.de
<span style="color: #000000; font-weight: bold;">*</span> updates: mirrors.prometeus.net
========================================= Matched: drbd =========================================
drbd.i686 : Distributed Replicated Block Device.
drbd-kmdl-2.6.32-131.0.15.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-131.12.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-131.2.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-131.4.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-131.6.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.14.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.18.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.18.2.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.24.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.29.1.el6.centos.plus.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.29.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.7.1.el6.i686.i686 : Distributed Redundant Block Device.</pre></div></div>

<p>
Nous pouvons installer le paquet <code>drbd</code> ainsi que le module du noyau correspondant au noyau en cours. Je vérifie quel noyau j&#8217;ai sur mon système :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># uname -r</span>
2.6.32-71.29.1.el6.i686</pre></div></div>

<p>
J&#8217;installe le module correspondant :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install drbd drbd-kmdl-2.6.32-71.29.1.el6.i686.i686</span></pre></div></div>

<p>
Il faut charger le nouveau module dans le noyau :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># modprobe drbd</span></pre></div></div>

<p>
Et bien sur on veut qu&#8217;il se charge au démarrage de la machine, on ajoute donc cette ligne au fichier <code>/etc/rc.local</code>.
</p>
<h4>Configuration</h4>
<p>
La configuration de DRBD se situe sous <code>/etc/drbd.conf</code>, mais pour plus de lisibilité, ce fichier fait appel à ceux situés sous <code>/etc/drbd.d/</code>, la configuration se fait donc d&#8217;une part dans <code>global_common.conf</code> pour la configuration commune et dans un fichier <code>r0.res</code> que nous allons créer pour notre nouvelle ressource. Ce nom r0 est arbitraire.<br />
Donc pour commencer, vérifier que le fichier <code>global_common.conf</code> possède les options suivantes :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">global <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  usage-count <span style="color: #c20cb9; font-weight: bold;">yes</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
common <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  net <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    protocol C;
    verify-alg sha1;
    csums-alg sha1;
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>
L&#8217;option <code>protocol C</code> signifie que la réplication s&#8217;effectue de façon synchrone. Avec ce mode de fonctionnement synchrone, l&#8217;écriture de données n&#8217;est considérée terminée que lorsque le nœud secondaire a terminé d&#8217;écrire, validant ainsi l&#8217;opération. <code>verify-alg sha1</code> <a href="http://www.drbd.org/users-guide/s-online-verify.html" title="drbd.org" target="_blank">vérifie l&#8217;intégrité des données</a> bloc par bloc entre les nœuds. <code>csums-alg sha1</code> active la synchronisation avec somme de contrôle (checksum). Comme expliqué dans la documentation, la synchronisation n&#8217;est pas la même chose que la réplication des périphériques. La seconde se fait en temps réel, c&#8217;est le fonctionnement normal de DRBD, alors que la première s&#8217;effectue lorsqu&#8217;il y a eu perte d&#8217;un des deux nœuds (pour quelque raison que ce soit) et une (re)synchronisation est nécessaire.
</p>
<p>
Il est temps de créer la vraie ressource dans un nouveau fichier <code>r0.res</code> contenant ces informations :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">resource r0 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	on mailsrv-ha1 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    	address   192.168.1.10:<span style="color: #000000;">7789</span>;
    	device    <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1;
		disk      <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>vg_storage-lv_storage;
		meta-disk internal;
  	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
  	on mailsrv-ha2 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    	address   192.168.1.11:<span style="color: #000000;">7789</span>;
    	device    <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1;
		disk      <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>vg_storage-lv_storage;
		meta-disk internal;
  	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>
Petite explication sur la configuration de cette ressource qui dans son ensemble parle d&#8217;elle-même. On définit les deux nœuds avec le mot-clé <code>on</code> suivi du nom de l&#8217;hôte. On spécifie l&#8217;IP du nœud et le port utilisé &#8211; ici 7789. Le périphérique de bloc logique est définit par <code>device</code> suivi du chemin vers celui-ci. Ensuite il faut indiquer la partition de bas niveau sur laquelle le périphérique de bloc logique se posera grace au mot-clé <code>disk</code> suivi de son chemin. <code>meta-disk internal</code> indique que la zone réservée aux données de contrôle sera sur la même partition, toujours au niveau bloc (plus d&#8217;<a href="http://www.drbd.org/users-guide/ch-internals.html" title="http://www.drbd.org/users-guide/ch-internals.html" target="_blank">informations sur ce sujet</a> sur la documentation officielle).
</p>
<p>
On voit que certaines options (presque toutes sauf l&#8217;IP) sont les mêmes, on peut donc simplifier notre fichier <code>r0.res</code> comme ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">resource r0 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	device    <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1;
    disk      <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>vg_storage-lv_storage;
    meta-disk internal;
	on mailsrv-ha1 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    	address   192.168.137.201:<span style="color: #000000;">7789</span>;
  	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
  	on mailsrv-ha2 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    	address   192.168.137.203:<span style="color: #000000;">7789</span>;
  	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<h4>Activation de la ressource</h4>
<p>
Voilà, tout est bien configuré, on peut activer la ressource. Je répète que le système de fichiers de bas niveau <code>/dev/mapper/vg_storage-lv_storage</code> doit être démonté et ne doit pas être formatté. Si tel est le cas, son contenu va de toutes façons être perdu.
</p>
<p>
On commence par créer les meta-données du périphérique :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm create-md r0</span></pre></div></div>

<p>
Si des erreurs sont retournées, c&#8217;est que le système de fichiers existe, on le détruit donc :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># dd if=/dev/zero of=/dev/mapper/vg_storage-lv_storage bs=1M count=128</span></pre></div></div>

<p>
On relance la commande de création des meta-données. Tout devrait bien se passer, on peut activer la ressource :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm up r0</span></pre></div></div>

<p>
Il faut faire de même sur l&#8217;autre nœud. Lorsque la deuxième machine est prête on initialise la première synchronisation par cette commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm primary --force r0</span></pre></div></div>

<p>
Alors que se passe-t-il? Lorsque la ressource est activée, les deux nœuds sont marquées comme secondaires, une première synchronisation est nécessaire, on va donc forcer (avec l&#8217;option <code>--force</code>) cette opération sur le nœud que l&#8217;on veut primaire.
</p>
<p>
A ce stade, il est possible de vérifier l&#8217;état de DRBD par la commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbd-overview </span>
  <span style="color: #000000;">1</span>:r0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>  SyncSource Primary<span style="color: #000000; font-weight: bold;">/</span>Secondary UpToDate<span style="color: #000000; font-weight: bold;">/</span>Inconsistent C r----- 
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">&gt;</span>....................<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #c20cb9; font-weight: bold;">sync</span><span style="color: #ff0000;">'ed:  0.6% (53340/53652)M</span></pre></div></div>

<p>
On voit que la ressource est en cours de synchronisation, suivant la taille de la partition, cela peut être long. On a plus d&#8217;info avec :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cat /proc/drbd </span>
version: 8.4.0 <span style="color: #7a0874; font-weight: bold;">&#40;</span>api:<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>proto:<span style="color: #000000;">86</span>-<span style="color: #000000;">100</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
GIT-hash: 28753f559ab51b549d16bcf487fe625d5919c49c build by gardner<span style="color: #000000; font-weight: bold;">@</span>, <span style="color: #000000;">2011</span>-08-<span style="color: #000000;">26</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">24</span>:<span style="color: #000000;">30</span>
&nbsp;
 <span style="color: #000000;">1</span>: cs:SyncSource ro:Primary<span style="color: #000000; font-weight: bold;">/</span>Secondary ds:UpToDate<span style="color: #000000; font-weight: bold;">/</span>Inconsistent C r-----
    ns:<span style="color: #000000;">1482108</span> nr:<span style="color: #000000;">0</span> dw:<span style="color: #000000;">0</span> dr:<span style="color: #000000;">1487544</span> al:<span style="color: #000000;">0</span> bm:<span style="color: #000000;">90</span> lo:<span style="color: #000000;">0</span> pe:<span style="color: #000000;">2</span> ua:<span style="color: #000000;">5</span> ap:<span style="color: #000000;">0</span> ep:<span style="color: #000000;">1</span> wo:b oos:<span style="color: #000000;">53461324</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">&gt;</span>....................<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #c20cb9; font-weight: bold;">sync</span><span style="color: #ff0000;">'ed:  2.7% (52208/53652)M
	finish: 0:41:59 speed: 21,216 (22,100) K/sec</span></pre></div></div>

<p>
On voit que le processus de synchronisation est en cours (<code>cs:SyncSource</code>), que le nœud primaire est à jour mais le secondaire est encore dans un étant incohérent (<code>ds:UpToDate/Inconsistent</code>).<br />
Il n&#8217;est pas nécessaire d&#8217;attendre la fin de la synchronisation pour créer le système de fichiers, donc allons-y, créons un système de fichiers <code>ext4</code> et montons-le :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mkfs.ext4 <span style="color: #660033;">-L</span> storage <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>storage
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>storage</pre></div></div>

<p>
Le système de fichiers est maintenant utilisable et va être répliqué en temps réel. On peut vérifier l&#8217;état de synchronisation :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cat /proc/drbd </span>
version: 8.4.0 <span style="color: #7a0874; font-weight: bold;">&#40;</span>api:<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>proto:<span style="color: #000000;">86</span>-<span style="color: #000000;">100</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
GIT-hash: 28753f559ab51b549d16bcf487fe625d5919c49c build by gardner<span style="color: #000000; font-weight: bold;">@</span>, <span style="color: #000000;">2011</span>-08-<span style="color: #000000;">26</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">24</span>:<span style="color: #000000;">30</span>
&nbsp;
 <span style="color: #000000;">1</span>: cs:Connected ro:Primary<span style="color: #000000; font-weight: bold;">/</span>Secondary ds:UpToDate<span style="color: #000000; font-weight: bold;">/</span>UpToDate C r-----
    ns:<span style="color: #000000;">56499808</span> nr:<span style="color: #000000;">36</span> dw:<span style="color: #000000;">1557816</span> dr:<span style="color: #000000;">54944894</span> al:<span style="color: #000000;">422</span> bm:<span style="color: #000000;">3354</span> lo:<span style="color: #000000;">0</span> pe:<span style="color: #000000;">0</span> ua:<span style="color: #000000;">0</span> ap:<span style="color: #000000;">0</span> ep:<span style="color: #000000;">1</span> wo:b oos:<span style="color: #000000;">0</span></pre></div></div>

<p>
Voilà, c&#8217;est fini, notre resource est connectée (<code>cs:Connected</code>), on est sur le noeud primaire (<code>ro:Primary/Secondary</code>) et elle est à jour des deux cotés (<code>ds:UpToDate/UpToDate</code>). Avec <code>drbd-overview</code> on obtient plus d&#8217;informations, en particulier sur la taille du stockage :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbd-overview </span>
  <span style="color: #000000;">1</span>:r0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>  Connected Primary<span style="color: #000000; font-weight: bold;">/</span>Secondary UpToDate<span style="color: #000000; font-weight: bold;">/</span>UpToDate C r----- <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>storage ext4 52G 730M 49G <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">%</span></pre></div></div>

<p>
Toute modification sur la ressource peut se faire en temps réel, après un changement, il faut copier le fichier de configuration sur le second nœud et opérer cette commande (sur les deux nœuds) :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm adjust r0</span></pre></div></div>

<h4>Vérification en ligne automatique</h4>
<p>
Nous avons vu que l&#8217;option <code>verify-alg</code> permet de vérifier l&#8217;intégrité des données en ligne, pour faire ce test il suffit d&#8217;invoquer la commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm verify r0</span></pre></div></div>

<p>
DRBD commence alors la vérification et s&#8217;il détecte des blocs non synchronisés, il les marque comme tel et l&#8217;inscrit dans le log du noyau. Il est bon d&#8217;automatiser cette tâche en l&#8217;ajoutant dans le <code>cron</code>. Pour ce faire, ajouter un fichier <code>/etc/cron.d/drbd-verify</code> avec &#8211; par exemple &#8211; ce contenu :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">42</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">0</span>    root    <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>drbdadm verify r0</pre></div></div>

<p>
Par ailleurs, si des blocs non synchronisés ont été détectés, il faut les re-synchroniser comme ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">drbdadm disconnect r0
drbdadm connect r0</pre></div></div>

<h4>Restauration manuelle après un split-brain</h4>
<p>
Un <a href="http://fr.wikipedia.org/wiki/Split-brain" title="Wikipedia : Split-brain" target="_blank">split-brain</a> se produit lorsque pour une raison quelconque les deux nœuds se retrouvent déconnectés, lorsque la connectivité revient, DRBD détecte que les 2 nœuds sont en mode primaire, DRBD rompt alors immédiatement la connexion de réplication par sécurité. Après le split-brain, un nœud passe en mode <code>StandAlone</code> et l&#8217;autre passe soit en mode secondaire ou en <code>WFConnection</code>. Il est temps d&#8217;intervenir.
</p>
<p>
Pour repartir sans corrompre les données &#8211; pour que le primaire sache qu&#8217;il est &laquo;&nbsp;maitre&nbsp;&raquo; &#8211; il faut aller sur le (futur) nœud secondaire et le déclarer comme tel, puis on connecte la ressource en lui disant d&#8217;oublier ses données :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">drbdadm secondary r0
drbdadm connect <span style="color: #660033;">--discard-my-data</span> r0</pre></div></div>

<p>
On passe sur le primaire que l&#8217;on connecte et que l&#8217;on déclare primaire :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">drbdadm connect r0
drbdadm primary r0</pre></div></div>

<p>
Notre ressource <code>r0</code> est repartie.
</p>
<h4>Tester la réplication</h4>
<p>
Il est temps de tester un peu le fonctionnement de la réplication. Créons un fichier quelconque de 500Mo sous <code>/mnt/storage</code> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># dd if=/dev/zero of=/mnt/storage/toto.dat bs=10M count=50</span>
<span style="color: #000000;">50</span>+<span style="color: #000000;">0</span> records <span style="color: #000000; font-weight: bold;">in</span>
<span style="color: #000000;">50</span>+<span style="color: #000000;">0</span> records out
<span style="color: #000000;">524288000</span> bytes <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">524</span> MB<span style="color: #7a0874; font-weight: bold;">&#41;</span> copied, <span style="color: #000000;">31.4183</span> s, <span style="color: #000000;">16.7</span> MB<span style="color: #000000; font-weight: bold;">/</span>s
<span style="color: #666666; font-style: italic;"># ls -l /mnt/storage/</span>
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> root root <span style="color: #000000;">524288000</span> Sep <span style="color: #000000;">22</span> <span style="color: #000000;">11</span>:04 toto.dat</pre></div></div>

<p>
Celui-ci devrait maintenant exister également sur <code>centos-ha2</code>, pour le vérifier il faut suivre les étapes suivantes, sur le primaire : démonter le système de fichiers, le passer en secondaire, et sur le secondaire : le passer en primaire et monter le système de fichiers. Cela donne :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># umount /mnt/storage</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># drbdadm secondary r0</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha2 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># drbdadm primary r0</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha2 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># mount /dev/drbd1 /mnt/storage</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha2 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ls -l /mnt/storage</span>
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> root root <span style="color: #000000;">524288000</span> Sep <span style="color: #000000;">22</span> <span style="color: #000000;">11</span>:04 toto.dat</pre></div></div>

<p>
Tout est parfait, même si cela semble un peu long. Il ne faut pas oublier que le système de fichiers sur le nœud secondaire n&#8217;est pas accessible en l&#8217;état (il n&#8217;est d&#8217;ailleurs pas monté). Dans un environnement de production, la manipulation est un peu fastidieuse, c&#8217;est pourquoi il vaut mieux utiliser un CRM (Cluster Resource management) &#8211; comme <a href="http://www.clusterlabs.org/wiki/Pacemaker" title="clusterlabs.org" target="_blank">Pacemaker</a> &#8211; qui fera ce travail automatiquement. Ce sera l&#8217;objet d&#8217;un prochain article.
</p>
<p style="text-align:right">
^.^
</p>
<hr />
<p><strong>Ressources :</strong></p>
<ul>
<li><a href="http://www.drbd.org/users-guide/drbd-users-guide.html" title="drbd.org" target="_blank">The DRBD User&#8217;s Guide</a></li>
<li><a href="http://fr.wikipedia.org/wiki/DRBD" title="Wikipedia : DRBD" target="_blank">Wikipedia : DRBD</a></li>
<li><a href="http://www.centos.org/" title="centos.org" target="_blank">CentOS 6</a></li>
<li><a href="http://atrpms.net/" title="atRPMS" target="_blank">Dépôt atRPMS</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/feub/werk/~4/ZHE3n3ORdUg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/09/drbd-centos-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2011/09/drbd-centos-6/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=drbd-centos-6</feedburner:origLink></item>
		<item>
		<title>Ajouter le support TLS à Postfix et Dovecot</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/TMjhaqlgWaU/</link>
		<comments>http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix-et-dovecot/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 13:16:57 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[mailserver]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[tls]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=858</guid>
		<description><![CDATA[TLS (qui s&#8217;appelait SSL avant 2001) signifie Transport Layer Security. Il s&#8217;agit d&#8217;une couche qui crypte la communication entre deux hôtes. En utilisant SMTP AUTH (voir cet article) avec les mécanismes PLAIN ou LOGIN, le nom d&#8217;utilisateur ainsi que le mot de passe transitent en clair et sont exposés à quiconque sniffe le réseau. C&#8217;est [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/05/Messagerie.png" alt="" title="" class="floatleft" /><a href="http://fr.wikipedia.org/wiki/Transport_Layer_Security" title="Wikipedia TLS" target="_blank">TLS</a> (qui s&#8217;appelait <a href="http://fr.wikipedia.org/wiki/Secure_Sockets_Layer" title="Wikipedia SSL" target="_blank">SSL</a> avant 2001) signifie Transport Layer Security. Il s&#8217;agit d&#8217;une couche qui crypte la communication entre deux hôtes. En utilisant <a href="http://fr.wikipedia.org/wiki/SMTP_AUTH" title="Wikipedia SMTP AUTH" target="_blank">SMTP AUTH</a> (<a href="http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/" title="Postfix SASL avec Dovecot">voir cet article</a>) avec les mécanismes PLAIN ou LOGIN, le nom d&#8217;utilisateur ainsi que le mot de passe transitent en clair et sont exposés à quiconque sniffe le réseau. C&#8217;est là que la couche TLS peut résoudre ce point faible.<br />
Pour utiliser le cryptage, il faut un <a href="http://fr.wikipedia.org/wiki/Certificat_%C3%A9lectronique" title="Wikipedia Certificat électronique" target="_blank">certificat</a> qui valide notre authenticité pour le client qui va se connecter au serveur de messagerie. Normalement un tel certificat doit s&#8217;acheter auprès d&#8217;une autorité compétente comme <a href="http://www.thawte.com/" title="Thawte" target="_blank">Thawte</a> ou <a href="http://www.verisign.com/" title="Verisign" target="_blank">Verisign</a>. L&#8217;autre solution est d&#8217;auto-signer son certificat, c&#8217;est bien entendu gratuit, mais n&#8217;étant pas <em>officiel</em> (mais reste légal!), les utilisateurs du serveur de messagerie devront vous faire confiance en acceptant ce certificat &laquo;&nbsp;maison&nbsp;&raquo;. Cette soluton est décrite ci-dessous.
</p>
<p><span id="more-858"></span></p>
<h4>Création du certificat</h4>
<p>
La création du certificat s&#8217;effectue avec la commande <code>openssl</code>, comme suit :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># openssl req -new -x509 -days 3650 -nodes -out /etc/postfix/mailserver.pem -keyout /etc/postfix/mailserver.pem</span></pre></div></div>

<p>
C&#8217;est parti pour une série de questions, peu importe les réponses données, seul le <em>Common Name</em> est important et doit refléter le nom d&#8217;hôte du serveur, dans notre exemple : <code>mail.example.net</code>. Le certificat sera valide 10 ans (10 x 365 jours).<br />
Il faut veiller à placer les bonnes permissions sur le fichier :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># chmod 600 /etc/postfix/mailserver.pem</span></pre></div></div>

<h4>Postfix</h4>
<p>
On ajoute les bonnes directives au <code>main.conf</code> de <a href="http://www.postfix.org/" title="Postfix" target="_blank">Postfix</a>, par exemple en fin de fichier :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">smtpd_tls_key_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>mailserver.pem
smtpd_tls_cert_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>mailserver.pem
smtpd_tls_security_level = encrypt
smtpd_tls_received_header = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>urandom
smtp_tls_loglevel = <span style="color: #000000;">3</span></pre></div></div>

<p>
Redémarrage de Postfix :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postfix reload</span></pre></div></div>

<p>
Tout est en place, le serveur SMTP devrait pouvoir instantier une connexion TLS maintenant, essayons en <a href="http://fr.wikipedia.org/wiki/Telnet" title="Wikipedia telnet" target="_blank">telnet</a>, si une nouvelle ligne <code>STARTTLS</code> apparait et que le serveur répond correctement, c&#8217;est tout bon :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ telnet mail.example.net <span style="color: #000000;">25</span>
Trying 91.127.162.55...
Connected to mail.example.net.
Escape character is <span style="color: #ff0000;">'^]'</span>.
<span style="color: #000000;">220</span> mail.example.net ESMTP Postfix
EHLO localhost
<span style="color: #000000;">250</span>-mail.example.net
<span style="color: #000000;">250</span>-PIPELINING
<span style="color: #000000;">250</span>-SIZE <span style="color: #000000;">10240000</span>
<span style="color: #000000;">250</span>-VRFY
<span style="color: #000000;">250</span>-ETRN
<span style="color: #000000;">250</span>-STARTTLS
<span style="color: #000000;">250</span>-AUTH PLAIN LOGIN
<span style="color: #000000;">250</span>-AUTH=PLAIN LOGIN
<span style="color: #000000;">250</span>-ENHANCEDSTATUSCODES
<span style="color: #000000;">250</span>-8BITMIME
<span style="color: #000000;">250</span> DSN</pre></div></div>

<p>
STARTTLS est bien présent, on tape la commande STARTTLS :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">STARTTLS
<span style="color: #000000;">220</span> 2.0.0 Ready to start TLS</pre></div></div>

<p>
La serveur dit qu&#8217;il est pret, sinon revoir ses certificats, les chemins et les bonne options dans <code>main.cf</code>. Cependant il reste un petit problème de sécurité, il faut que l&#8217;authentification SMTP AUTH PLAIN ne soit disponible que lorsque l&#8217;utilisateur utilise TLS. Ainsi Postfix va effectuer le SMTP AUTH uniquement après que la couche soit TLS soit établie. Pour ce faire il suffit de rajouter cette ligne au <em>main.cf</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">smtpd_tls_auth_only = <span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>
On redémarre Postfix :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postfix reload</span></pre></div></div>

<p>
On re-telnet :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ telnet mail.example.net <span style="color: #000000;">25</span>
Trying 91.127.162.55...
Connected to mail.example.net.
Escape character is <span style="color: #ff0000;">'^]'</span>.
<span style="color: #000000;">220</span> mail.example.net ESMTP Postfix
EHLO localhost
<span style="color: #000000;">250</span>-mail.example.net
<span style="color: #000000;">250</span>-PIPELINING
<span style="color: #000000;">250</span>-SIZE <span style="color: #000000;">10240000</span>
<span style="color: #000000;">250</span>-VRFY
<span style="color: #000000;">250</span>-ETRN
<span style="color: #000000;">250</span>-STARTTLS
<span style="color: #000000;">250</span>-ENHANCEDSTATUSCODES
<span style="color: #000000;">250</span>-8BITMIME
<span style="color: #000000;">250</span> DSN</pre></div></div>

<p>
On voit que maintenant SMTP AUTH ne sera disponible qu&#8217;après avoir établit la liaison TLS (les lignes AUTH ne sont plus visibles à ce niveau).
</p>
<h4>Dovecot SSL</h4>
<p>
Au tour de Dovecot de passer en SSL. C&#8217;est très simple, nous allons utiliser le même certificat que pour Postfix. On ajoute les lignes suivantes au fichier <code>dovecot.conf</code> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">protocols = imap imaps
ssl_disable = no
<span style="color: #666666; font-style: italic;"># ssl = yes pour les versions supérieures à v1.2.beta1</span>
ssl_cert_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>postfix.pem
ssl_key_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>postfix.pem
verbose_ssl = <span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>
Un petit rappel sur les permissions du certificat qui ne doit etre accessible que par l&#8217;utilisateur root : <code>root:root 0444</code>. Autre petit point qui a son importance, on refuse désormais les connexions LOGIN à moins que TLS/SSL soit établi. Pour ce faire, on modifie cette ligne :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">disable_plaintext_auth = <span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>
On re-démarre le serveur IMAP :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service dovecot restart</span></pre></div></div>

<p>
On peut le tester :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ openssl s_client <span style="color: #660033;">-connect</span> mail.example.net:imaps
CONNECTED<span style="color: #7a0874; font-weight: bold;">&#40;</span>00000003<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">depth</span>=<span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
verify error:<span style="color: #007800;">num</span>=<span style="color: #000000;">18</span>:self signed certificate
verify <span style="color: #7a0874; font-weight: bold;">return</span>:<span style="color: #000000;">1</span>
<span style="color: #007800;">depth</span>=<span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
verify <span style="color: #7a0874; font-weight: bold;">return</span>:<span style="color: #000000;">1</span>
<span style="color: #660033;">---</span>
Certificate chain
 <span style="color: #000000;">0</span> s:<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
   i:<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #660033;">---</span>
Server certificate
<span style="color: #660033;">-----BEGIN</span> CERTIFICATE-----
MIIDojCCAwugAwIBAgIJAKn3cs1HiGLvMA0GCSqGSIb3DQEBBQUAMIGTMQswCQYD
VQQGEwJJVDEOMAwGA1UECBMFTGF6aW8xDTALBgNVBAcTBFJvbWExFzAVBgNVBAoT
DmZhYmllbmFtYW5uLmV1MRMwEQYDVQQLEwptYWlsc2VydmVyMRwwGgYDVQQDExNt
YWlsLmZhYmllbmFtYW5uLmV1MRkwFwYJKoZIhvcNAQkBFgpfQGZldWIubmV0MB4X
DTExMDgwNDEzNTY1OFoXDTIxMDgwMTEzNTY1OFowgZMxCzAJBgNVBAYTAklUMQ4w
DAYDVQQIEwVMYXppbzENMAsGA1UEBxMEUm9tYTEXMBUGA1URChMOZmFiaWVuYW1h
bm4uZXUxEzARBgNVBAsTCm1haWxzZXJ2ZXIxHDAaBgNVBAMTE21haWwuZmFiaWVu
YW1hbm4uZXUxGTAXBgkqhkiG9w0BCQEWCmZAZmV1Yi5uZXQwgZ8wDQYJKoZIhvcN
AQEBBQADgY0AMIGJAoGBAO5esAspC+j2yVIPRsSQ6aUsbR+8iS<span style="color: #000000; font-weight: bold;">/</span>u5H4LgwL8OQd5
799lXzG9hWmn0uMR+6SutjgDFbDL+<span style="color: #c20cb9; font-weight: bold;">w</span>+zdXzGZ2UQi6OjKjKo+L<span style="color: #000000; font-weight: bold;">/</span>pwEkdokRRIpNw
mhyIum+F+7XcfP1KHdVQu85cDphd+rhPDkDtYNUMD8Nd8ClmaftTeVVaV5T1MEGt
AgMBAAGjgfswfafaHQYDVR0OBBYEFKCxvAc+P1gk+ILQWc3NXvdxNxYRMIHIBgNV
HSMEgcAwgb2AFKCxvAc+P1gk+ILQWc3nXvdxNxYRoYGZpIGWMIGTMQswCQYDVQQG
EwJJVDEOMAwGA1UECBMFTGF6aW8xDTALBgNVBAcTBFJvbWEXFzAVBgNVBAoTDmZh
YmllbmFtYW5uLmV1MRMwEQYDVQQLEwptYWlsc2VydmVyMRwwGgYDVQQDExNtYWls
LmZhYmllkikiFtYW5uLmV1MRkwFwYJKoZIhvcNAQkBFgpmQGZldWIuV0ggkAqfdy
zUeIYu8wDAYDVR0TBAUwAwEB<span style="color: #000000; font-weight: bold;">/</span>zANBgkqhdiG9w0BAQUFAAOBgQAyESbxZh8WID39
Qwr<span style="color: #000000; font-weight: bold;">/</span>NjotqatAsKqGXCIuW5WROo+7ZVvmPoVx<span style="color: #000000; font-weight: bold;">/</span>OLvnYQnF5DzCnMF<span style="color: #000000; font-weight: bold;">/</span>9E7kuiW2feg
BmQPYT5UXU5cH2R5fBkT<span style="color: #000000; font-weight: bold;">/</span>bnIgPTEr33L75RFDWiKE4vKzvtTDneUIWxXxw+goGOz
SK3TyKQawclFSbVC9nvBixw5+<span style="color: #000000;">4</span><span style="color: #007800;">hbfg</span>==
<span style="color: #660033;">-----END</span> CERTIFICATE-----
<span style="color: #007800;">subject</span>=<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #007800;">issuer</span>=<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #660033;">---</span>
No client certificate CA names sent
<span style="color: #660033;">---</span>
SSL handshake has <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #000000;">1505</span> bytes and written <span style="color: #000000;">319</span> bytes
<span style="color: #660033;">---</span>
New, TLSv1<span style="color: #000000; font-weight: bold;">/</span>SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is <span style="color: #000000;">1024</span> bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : DHE-RSA-AES256-SHA
    Session-ID: 7A7619EB698CEF9463774C06E6729F0A2CE9D9E551DD96439C00D7BA3001641D1
    Session-ID-ctx: 
    Master-Key: 89E6DA90F03046C65F4C330A9D24209D3260A4DE134EC4287D6516B344AFBE80BCAE0FDCE037177B384E2F166C17CBCE
    Key-Arg   : None
    Krb5 Principal: None
    Start Time: <span style="color: #000000;">1312960774</span>
    Timeout   : <span style="color: #000000;">300</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>sec<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    Verify <span style="color: #7a0874; font-weight: bold;">return</span> code: <span style="color: #000000;">18</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>self signed certificate<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #660033;">---</span>
<span style="color: #000000; font-weight: bold;">*</span> OK Dovecot ready.</pre></div></div>

<p>
Le serveur de messagerie est maintenant plus sécurisé avec cette couche TLS/SSL qui crypte les communications et authentifie l&#8217;identité du serveur. L&#8217;utilisation d&#8217;un cryptage à clé publique permet au client de vérifier que le serveur possède un certificat valide et ainsi ce client sait pour des utilisations ultérieures qu&#8217;il peut faire confiance à ce serveur. L&#8217;utilisateur qui se connecte est également vérifié dans ce processus.
</p>
<hr />
<h4>En complément :</h4>
<ul>
<li>Première partie : <a href="http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/"><strong>Serveur de messagerie simple avec Postfix et Dovecot</strong></a></li>
<li>Deuxième partie : <a href="http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/" title="Postfix SASL avec Dovecot"><strong>Postfix SASL avec Dovecot</strong></a></li>
<li>Troisième partie : Ajouter le support TLS à Postfix</li>
<li><a href="http://www.postfix.org/" title="Postfix" target="_blank">http://www.postfix.org/</a></li>
<li><a href="http://www.dovecot.org/" title="Dovecot" target="_blank">http://www.dovecot.org/</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/feub/werk/~4/TMjhaqlgWaU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix-et-dovecot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix-et-dovecot/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=ajouter-le-support-tls-a-postfix-et-dovecot</feedburner:origLink></item>
		<item>
		<title>Postfix SASL avec Dovecot</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/OoO01kUogf8/</link>
		<comments>http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 11:02:45 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[messagerie]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[sasl]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=838</guid>
		<description><![CDATA[L&#8217;authentification SMTP (SMTP Auth) est un mécanisme de contrôle d&#8217;accès qui permet de ne relayer que les utilisateurs autorisés, ainsi toute personne non authentifiée est rejetée. Depuis la version 2.3, Postfix supporte SMTP AUTH au travers de Dovecot SASL (introduit depuis Dovecot 1.0). Il est possible de vérifier si votre installation de Postfix est compilée [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/05/Messagerie.png" alt="" title="" class="floatleft" />L&#8217;<a href="http://fr.wikipedia.org/wiki/Internet_message_access_protocol_authentication" title="Wikipedia SMTP auth" target="_blank">authentification SMTP</a> (SMTP Auth) est un mécanisme de contrôle d&#8217;accès qui permet de ne relayer que les utilisateurs autorisés, ainsi toute personne non authentifiée est rejetée. Depuis la version 2.3, <a href="http://www.postfix.org/" title="Postfix" target="_blank">Postfix</a> supporte SMTP AUTH au travers de Dovecot <a href="http://fr.wikipedia.org/wiki/SASL" title="Wikipedia SASL" target="_blank">SASL</a> (introduit depuis Dovecot 1.0). Il est possible de vérifier si votre installation de Postfix est compilée avec le support de SASL avec la commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postconf -a</span></pre></div></div>

<p><span id="more-838"></span></p>
<h4>Configurer Dovecot SASL</h4>
<p>
Le server POP/IMAP <a href="http://www.dovecot.org/" title="Dovecot" target="_blank">Dovecot</a> possède bien entendu son propre système d&#8217;authentification des clients POP/IMAP. Lorsque Postfix utilise Dovecot SASL, celui-ci ré-utilise cette configuration. La communication se fait par l&#8217;intermédiaire d&#8217;un <a href="http://fr.wikipedia.org/wiki/Sockets_du_domaine_UNIX">socket Unix</a>. Le chemin vers ce socket ainsi que la liste des méthodes d&#8217;authentification proposées doivent être spécifiées dans <code>dovecot.conf</code>. Voici ce qu&#8217;il faut ajouter au fichier de configuration de Dovecot existant :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">auth default <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  mechanisms = plain <span style="color: #c20cb9; font-weight: bold;">login</span>  
  socket listen <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    client <span style="color: #7a0874; font-weight: bold;">&#123;</span>
      <span style="color: #666666; font-style: italic;"># Un socket est exporté pour pouvoir etre utilisé par un client.</span>
      <span style="color: #666666; font-style: italic;"># Ici c'est notre serveur SMTP Postfix</span>
      path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>auth-client
      mode = 0660
      user = postfix
      group = postfix
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>On relance Dovecot :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service dovecot restart</span></pre></div></div>

<h4>La partie Postfix</h4>
<p>
Maintenant il faut dire à Postfix comment utiliser SASL. Par défaut celui-ci gère du <a href="http://www.postfix.org/SASL_README.html#server_sasl" title="Postfix" target="_blank">Cyrus SASL</a>, il faut donc explicitement lui dire que l&#8217;on utilise le mécanisme de Dovecot, on renseigne le chemin vers le socket et on lui passe quelques options de sécurité. Voici la partie SASL à ajouter au <code>main.cf</code> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># On utilise le SASL de Dovecot</span>
smtpd_sasl_type = dovecot
<span style="color: #666666; font-style: italic;"># Chemin vers le socket Unix</span>
smtpd_sasl_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>auth-client
<span style="color: #666666; font-style: italic;"># On active le SASL</span>
smtpd_sasl_auth_enable = <span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #666666; font-style: italic;"># Quelques options de sécurité assez parlantes</span>
smtpd_recipient_restrictions =  permit_mynetworks,
    permit_sasl_authenticated, reject_unauth_destination
<span style="color: #666666; font-style: italic;"># Ceci assure une compatibilité avec d'anciens clients (Outlook par ex.)</span>
broken_sasl_auth_clients = <span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #666666; font-style: italic;"># Pas de connexions anonymes</span>
smtpd_sasl_security_options = noanonymous</pre></div></div>

<p>On re-charge Postfix :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postfix reload</span></pre></div></div>

<h4>Test de la configuration</h4>
<p>
La configuration est terminée, il est temps de tester le bon fonctionnement du SMTP Auth en <a href="http://fr.wikipedia.org/wiki/Telnet" title="Wikipedia telnet" target="_blank">telnet</a>:
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ telnet mail.example.net <span style="color: #000000;">25</span>
Trying 90.112.151.15...
Connected to mail.example.net.
Escape character is <span style="color: #ff0000;">'^]'</span>.
<span style="color: #000000;">220</span> mail.example.net ESMTP Postfix
EHLO localhost
<span style="color: #000000;">250</span>-mail.example.net
<span style="color: #000000;">250</span>-PIPELINING
<span style="color: #000000;">250</span>-SIZE <span style="color: #000000;">10240000</span>
<span style="color: #000000;">250</span>-VRFY
<span style="color: #000000;">250</span>-ETRN
<span style="color: #000000;">250</span>-AUTH PLAIN LOGIN
<span style="color: #000000;">250</span>-AUTH=PLAIN LOGIN
<span style="color: #000000;">250</span>-ENHANCEDSTATUSCODES
<span style="color: #000000;">250</span>-8BITMIME
<span style="color: #000000;">250</span> DSN</pre></div></div>

<p>
On voit les deux lignes AUTH indiquant que le SASL est pris en compte. Pourquoi deux lignes? La deuxième avec le signe égal est pour la compatibilité avec les anciens clients (option : <code>broken_sasl_auth_clients = yes</code>).
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">MAIL FROM:<span style="color: #000000; font-weight: bold;">&lt;</span>lulu<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000;">250</span> 2.1.0 Ok
RCPT TO: fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #000000;">554</span> 5.7.1 <span style="color: #000000; font-weight: bold;">&lt;</span>fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net<span style="color: #000000; font-weight: bold;">&gt;</span>: Relay access denied</pre></div></div>

<p>
La connexion est refusée, il faut maintenant penser à s&#8217;authentifier avec la commande AUTH. Mais attention, en telnet il est nécessaire d&#8217;encoder le couple nom d&#8217;utilisateur/mot de passe en <a href="http://fr.wikipedia.org/wiki/Base64" title="Wikipedia base64" target="_blank">base64</a>, par exemple avec :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">'\000username\000password'</span> <span style="color: #000000; font-weight: bold;">|</span> openssl base64</pre></div></div>

<p>
Ce qui donne :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">AUTH PLAIN AGhvbnTHY3RAZmDiavVuKikI7hbm5uZVBAc3BjKXRuoJWsK
<span style="color: #000000;">235</span> 2.0.0 Authentication successful
RCPT TO: fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #000000;">250</span> 2.1.5 Ok
DATA
<span style="color: #000000;">354</span> End data with <span style="color: #000000; font-weight: bold;">&lt;</span>CR<span style="color: #000000; font-weight: bold;">&gt;&lt;</span>LF<span style="color: #000000; font-weight: bold;">&gt;</span>.<span style="color: #000000; font-weight: bold;">&lt;</span>CR<span style="color: #000000; font-weight: bold;">&gt;&lt;</span>LF<span style="color: #000000; font-weight: bold;">&gt;</span>
Yes<span style="color: #000000; font-weight: bold;">!</span>
.
<span style="color: #000000;">250</span> 2.0.0 Ok: queued <span style="color: #c20cb9; font-weight: bold;">as</span> E72163EB1E
quit
<span style="color: #000000;">221</span> 2.0.0 Bye
Connection closed by foreign host.</pre></div></div>

<p>
Le message devrait être délivré sous peu ^.^
</p>
<hr />
<h4>En complément :</h4>
<ul>
<li>Première partie : <a href="http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/"><strong>Serveur de messagerie simple avec Postfix et Dovecot</strong></a></li>
<li>Deuxième partie : Postfix SASL avec Dovecot</li>
<li>Troisième partie : <a href="http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix/" title="Ajouter le support TLS à Postfix"><strong>Ajouter le support TLS à Postfix</strong></a></li>
<li><a href="http://www.postfix.org/" title="Postfix" target="_blank">http://www.postfix.org/</a></li>
<li><a href="http://www.dovecot.org/" title="Dovecot" target="_blank">http://www.dovecot.org/</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/feub/werk/~4/OoO01kUogf8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=postfix-sasl-avec-dovecot</feedburner:origLink></item>
		<item>
		<title>Fedora au boulot</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/Zze8gZOyxZs/</link>
		<comments>http://werk.feub.net/2011/07/fedora-au-boulot/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 18:05:04 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[3615 tavie]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[boulot]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gnome 3]]></category>
		<category><![CDATA[gnome shell]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rome]]></category>
		<category><![CDATA[travail]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=709</guid>
		<description><![CDATA[Bien qu&#8217;étant utilisateur de GNU/Linux depuis un bon nombre d&#8217;années, je n&#8217;ai quasiment jamais eu ma station de travail sous Linux dans ma vie professionnelle. On a rarement le choix, on bosse pour une boite, on nous donne une machine et c&#8217;est dans la grande majorité des cas du Windows. Dans le cadre de mon [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="/medias/2010/03/fedora-logo_64.png" alt="" title="" class="floatleft" />Bien qu&#8217;étant utilisateur de GNU/Linux depuis un bon nombre d&#8217;années, je n&#8217;ai quasiment jamais eu ma station de travail sous Linux dans ma vie professionnelle. On a rarement le choix, on bosse pour une boite, on nous donne une machine et c&#8217;est dans la grande majorité des cas du Windows. Dans le cadre de mon <a href="http://werk.feub.net/2011/01/ingredients-php-db2-et-unixodbc/">nouveau boulot</a> &#8211; presque un an maintenant quand même ^.^ &#8211; j&#8217;ai longtemps bossé sur un Windows 7 imposé, mais il y a de cela quelques mois, lors du renouvellement de ma machine, j&#8217;ai fait la requête de pouvoir installer <em>autre chose</em> et mon <em>management</em> n&#8217;y a pas vu d&#8217;objection pourvu que je puisse faire mon travail. Quel bonheur!
</p>
<p><span id="more-709"></span></p>
<p>
Je suis donc sur une machine en <a href="http://fedoraproject.org/">Fedora <del datetime="2011-06-07T07:11:02+00:00">14</del> 15</a> et voici un petit descriptif de ma config et des quelques outils que j&#8217;utilise. Je précise qu&#8217;il y a de l&#8217;Open-Source ET du propriétaire. Je suis un grand défenseur du <em>libre</em>, mais je pense également qu&#8217;il y a des limites et qu&#8217;à partir d&#8217;un certain moment la productivité est la priorité par rapport aux <em>principes</em> (et bien sur si je ne peux pas travailler, mon patron ne sera pas content).<br />
Je suis toujours ouvert aux propositions que vous pouvez soumettre dans les commentaires, c&#8217;est même un peu le but de ce billet, d&#8217;échanger des idées et des points de vue :)
</p>
<p>
Donc, en vrac, je suis sous Fedora 15 et l&#8217;<a href="http://werk.feub.net/2011/06/perdu-help/" title="Perdu. Help.">adaptation est un peu chahotique</a>, mais on s&#8217;adapte. A propos de <a href="http://werk.feub.net/2011/06/perdu-help/" title="Perdu. Help.">ce billet</a> de début juin, je suis depuis retourné vers <a href="http://gnome3.org/">Gnome 3</a>, bien sur avec l&#8217;aide de <a href="https://live.gnome.org/GnomeTweakTool">Gnome Tweak Tool</a> qui facilite un peu l&#8217;expérience.
</p>
<h4>Développement web</h4>
<p>
Mon principal job étant le développement <a href="http://fr.wikipedia.org/wiki/Php">PHP</a> (avec <a href="http://fr.wikipedia.org/wiki/Mysql">MySQL</a> et <a href="http://fr.wikipedia.org/wiki/DB2">DB2</a>), j&#8217;utilise <a href="http://netbeans.org/">Netbeans</a> comme <a href="http://fr.wikipedia.org/wiki/Environnement_de_d%C3%A9veloppement_int%C3%A9gr%C3%A9">IDE</a>, mais je dois dire que l&#8217;ergonomie et certaines fonctionalités de <a href="http://www.adobe.com/products/dreamweaver.html">Dreamweaver</a> me manquent énormément, et le faire tourner sous <a href="http://www.winehq.org/">Wine</a> ou en <a href="http://www.virtualbox.org/">VM</a> ne sont pas des solutions pour moi.
</p>
<h4>Partie graphique</h4>
<p>
Coté design graphique, c&#8217;est un peu beaucoup à la traine, je n&#8217;ai jamais supporté <a href="http://www.gimp.org/">The GIMP</a>, désolé, je jongle donc entre celui-ci pour les petites retouches rapides et <a href="http://www.adobe.com/products/photoshop.html">Photoshop</a> en VM pour le plus sérieux.
</p>
<h4>Administration machines</h4>
<p>
J&#8217;administre également des serveurs GNU/Linux (<a href="http://www.centos.org/">CentOS</a>) et Windows avec <a href="http://www.tenshu.net/terminator/">Terminator</a> et <a href="http://sourceforge.net/projects/gnome-rdp/">Gnome-RDP</a>.
</p>
<p>
Voilà donc un peu mon environnement général, sans rentrer dans les détails. Visuellement mon bureau Fedora / Gnome Shell ressemble à celà au jour d&#8217;aujourd&#8217;hui :
</p>
<div style="margin-bottom:15px">
<a href="http://werk.feub.net/medias/2011/07/20110706-desktop1.png" rel="lightbox[709]" title="Fedora au boulot"><img src="/medias/2011/07/20110706-desktop1-s.png" alt="" title="" width="620" height="388" /></a>
</div>
<div style="margin-bottom:15px">
<a href="http://werk.feub.net/medias/2011/07/20110706-desktop2.png" rel="lightbox[709]" title="Fedora au boulot"><img src="/medias/2011/07/20110706-desktop2-s.png" alt="" title="" width="620" height="388" /></a>
</div>
<img src="http://feeds.feedburner.com/~r/feub/werk/~4/Zze8gZOyxZs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/07/fedora-au-boulot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2011/07/fedora-au-boulot/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=fedora-au-boulot</feedburner:origLink></item>
		<item>
		<title>Perdu. Help.</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/u0TLHkupI2Q/</link>
		<comments>http://werk.feub.net/2011/06/perdu-help/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 13:02:29 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[desktop manager]]></category>
		<category><![CDATA[gestionnaire de bureaux]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gnome 3]]></category>
		<category><![CDATA[gnome shell]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[lxde]]></category>
		<category><![CDATA[xfce]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=809</guid>
		<description><![CDATA[Derrière ce court titre se cache ma détresse depuis plus d&#8217;une semaine avec ma Fedora 15 et le gros changement de Gnome 3/Gnome Shell. J&#8217;y ai gouté, sans réellement chercher à l&#8217;aimer je me suis dit que je n&#8217;allais pas faire ma mauvaise tête et qu&#8217;il fallait juste s&#8217;y mettre et s&#8217;adapter, je m&#8217;y suis [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/06/lost.jpg" alt="" class="floatleft" />Derrière ce court titre se cache ma détresse depuis plus d&#8217;une semaine avec ma <a href="http://fedoraproject.org/">Fedora 15</a> et le gros changement de <a href="http://gnome3.org/">Gnome 3/Gnome Shell</a>. J&#8217;y ai gouté, sans réellement chercher à l&#8217;aimer je me suis dit que je n&#8217;allais pas faire ma mauvaise tête et qu&#8217;il fallait juste s&#8217;y mettre et s&#8217;adapter, je m&#8217;y suis donc mis. Mais voilà, j&#8217;ai du boulot et je ne peux pas me permettre de perdre trop de temps à re-découvrir des choses de base (ou essayer de chercher des choses qui n&#8217;existent tout bonnement plus&#8230;), mon boss ayant un peu les yeux derrière mon dos ^.^
</p>
<p>
J&#8217;ai donc décidé de m&#8217;essayer à &#8230;. <a href="http://www.kde.org/">KDE</a>, et j&#8217;ai été plutot séduit (mention +++ pour le gestionnaire de fichiers <a href="http://www.krusader.org/">Krusader</a>), mais après quelques heures de boulot, mes ressources enflaient et ma machine devenait vraiment lente. J&#8217;ai donc viré du coté de <a href="http://www.xfce.org/">XFCE</a> que je connais un peu pour l&#8217;avoir utilisé sur quelques serveurs avec gestionnaire de bureaux. Mais, car il y a encore une fois un mais, il me manquait des choses, je n&#8217;étais pas à l&#8217;aise et je ressentais trop de limites. Après un re-passage à Gnome 3 et en ce moment depuis 2 jours sous <a href="http://lxde.org/">LXDE</a> qui ne me convient pas vraiment non plus (encore plus léger que XFCE, mais c&#8217;est le but du projet), je lance un appel à l&#8217;aide et des conseils de votre part, vos retours d&#8217;expériences ou simplement savoir sur quoi vous travaillez.
</p>
<p>
J&#8217;attends vos inspirations dans les commentaires, merci ^.^
</p>
<p>
<strong>Update 17/06/2011 :</strong> Mon choix n&#8217;est pas gravé dans le marbre, mais depuis ce billet je suis un utilisateur KDE, il me convient plutôt bien, même si des petites choses me chagrinent, mais c&#8217;est seulement parce que je n&#8217;ai pas trouvé le temps pour <em>tweaker</em> tout ça.
</p>
<p>
<a href="http://www.geograph.org.uk/photo/122440">Crédit photo.<br />
</a></p>
<img src="http://feeds.feedburner.com/~r/feub/werk/~4/u0TLHkupI2Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/06/perdu-help/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2011/06/perdu-help/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=perdu-help</feedburner:origLink></item>
		<item>
		<title>Serveur de messagerie simple avec Postfix et Dovecot</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/JJbRSxQUBiA/</link>
		<comments>http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/#comments</comments>
		<pubDate>Fri, 13 May 2011 13:37:51 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[courrier]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[maildir]]></category>
		<category><![CDATA[mailserver]]></category>
		<category><![CDATA[mta]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=796</guid>
		<description><![CDATA[Ce tutoriel aide à la mise en oeuvre d&#8217;un serveur de messagerie complet, par serveur simple, j’entends par là, pas de SSL, de MySQL et de fonctions avancées. Ces fonctions viendront par la suite dans de prochains articles. La solution proposée est à base de Postfix pour le MTA et Dovecot comme serveur IMAP. Il [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/05/Messagerie.png" alt="" title="" class="floatleft" />Ce tutoriel aide à la mise en oeuvre d&#8217;un serveur de messagerie complet, par serveur <em>simple</em>, j’entends par là, pas de <a href="http://fr.wikipedia.org/wiki/SSL">SSL</a>, de <a href="http://fr.wikipedia.org/wiki/Mysql">MySQL</a> et de fonctions <em>avancées</em>. Ces fonctions viendront par la suite dans de prochains articles. La solution proposée est à base de <a title="Postfix" href="http://www.postfix.org/">Postfix</a> pour le <a title="Wikipedia" href="http://fr.wikipedia.org/wiki/Mail_Transfer_Agent">MTA</a> et <a title="Dovecot" href="http://www.dovecot.org/">Dovecot</a> comme serveur <a title="Wikipedia" href="http://fr.wikipedia.org/wiki/IMAP">IMAP</a>.
</p>
<p>
Il gérera des boîtes aux lettres virtuelles – c’est-à-dire indépendantes des comptes <em>systèmes</em> – d’autant d’utilisateurs et de domaines que ce soit.
</p>
<p>
Pour la suite des opérations, la machine utilisée est sous <a title="fedora-fr.org" target="_blank" href="http://www.fedora-fr.org">Fedora</a>, le tutoriel pourra donc convenir aux utilisateurs de <a href="http://www.centos.org/">CentOS</a> et de <a href="http://www.redhat.com/rhel/">Red Hat</a>. On supposera qu&#8217;elle s’appelle <em>monhostname.local.mondomaine.net</em>. C&#8217;est parti ^.^
</p>
<h4>Postfix</h4>
<p>L&#8217;installation se fait naturellement avec <em>yum</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install postfix</span></pre></div></div>

<p>
Afin de préparer le terrain, il faut créer l’arborescence qui accueillera les boîtes aux lettres virtuelles et l’utilisateur/groupe de celles-ci. Pour ce faire, ajouter un utilisateur <em>vmail</em> et un groupe du même nom ayant tout deux des uid et gid non réservés, par exemple 6000. Le home de cet utilisateur sera <em>/home/vmail</em>, c’est ici que les BAL seront construites :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># groupadd -g 6000 vmail</span>
<span style="color: #666666; font-style: italic;"># useradd -d /home/vmail -m -u 6000 -g 6000 -s /dev/null vmail</span></pre></div></div>

<p>
On change les droits et le propriétaire des répertoires pour plus de sécurité :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># chmod -R 750 /home/vmail/</span>
<span style="color: #666666; font-style: italic;"># chown -R vmail:vmail /home/vmail/</span></pre></div></div>

<p>
Les fichiers de configuration Postfix se situent sous <em>/etc/postfix</em> et c’est <em>main.conf</em> qui nous intéresse. Je vais juste copier-coller le mien ci-dessous, pour plus de renseignement sur ses paramètres, voir <a title="feub.net" target="_blank" href="http://werk.feub.net/2011/01/activer-postfix-sous-mac-os-x/">cet article</a>.
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">alias_database = <span style="color: #007800;">$alias_maps</span>
alias_maps = <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = <span style="color: #c20cb9; font-weight: bold;">yes</span>
command_directory = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin
config_directory = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix
daemon_directory = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>postfix
data_directory = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postfix
debug_peer_level = <span style="color: #000000;">2</span>
delay_warning_time = 4h
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailbox_transport = lmtp:unix:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>imap<span style="color: #000000; font-weight: bold;">/</span>socket<span style="color: #000000; font-weight: bold;">/</span>lmtp
mailbox_size_limit = <span style="color: #000000;">512000000</span>
mailq_path = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mailq.postfix
manpage_directory = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">man</span>
masquerade_domains = mondomaine.net
message_size_limit = <span style="color: #000000;">50000000</span>
mydestination = <span style="color: #007800;">$myhostname</span>, localhost.<span style="color: #007800;">$myhostname</span>, localhost
mydomain = mondomaine.net
myhostname = monhostname.local.mondomaine.net
mynetworks = 192.168.1.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span>, 127.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>
myorigin = <span style="color: #007800;">$myhostname</span>
newaliases_path = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>newaliases
queue_directory = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>postfix
readme_directory = no
recipient_delimiter = +
relayhost = <span style="color: #7a0874; font-weight: bold;">&#91;</span>smtp.sfr.fr<span style="color: #7a0874; font-weight: bold;">&#93;</span>
sendmail_path = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sendmail</span>
setgid_group = postdrop
smtp_generic_maps = <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>generic
smtpd_banner = <span style="color: #007800;">$myhostname</span> ESMTP
smtpd_recipient_limit = <span style="color: #000000;">50</span>
unknown_local_recipient_reject_code = <span style="color: #000000;">550</span>
virtual_alias_maps = <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>user_aliases
virtual_gid_maps = static:<span style="color: #000000;">6000</span>
virtual_mailbox_base = <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vmail
virtual_mailbox_domains = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>domains
virtual_mailbox_limit = <span style="color: #000000;">512000000</span>
virtual_mailbox_maps = <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>user_mailboxes_path
virtual_minimum_uid = <span style="color: #000000;">6000</span>
virtual_uid_maps = static:<span style="color: #000000;">6000</span></pre></div></div>

<p>
<span style="text-decoration: underline;">Astuce</span> : Si comme moi, le serveur est sur un domaine local (monhostname.local.mondomaine.net), quelques difficultés vont être rencontrées lors de l’envoi de message vers l’extérieur, la machine de relai [smtp.sfr.fr] va refuser d’acheminer les emails car le domaine n’est pas enregistré sur la toile : <code>Sender address rejected: Domain not found</code>. Pour remédier à cela, il faut substituer l’adresse de l’émetteur en ajoutant ceci dans <em>/etc/postfix/generic</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">@</span>monhostname.local.mondomaine.net       <span style="color: #000000; font-weight: bold;">@</span>mondomaine.net</pre></div></div>

<p>On compile ce fichier avec <em>postmap</em> avant de relancer Postfix :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postmap /etc/postfix/generic</span></pre></div></div>

<p>
Pour savoir où délivrer le courrier, le système va lire le nom des domaines virtuels gérés dans le fichier <em>domains</em> et les adresses emails ainsi que leur chemin seront dans <em>user_mailboxes_path</em>, tout deux toujours sous <em>/etc/postfix</em>. Il suffit d’ajouter des domaines séparés par des retours ligne, comme suit :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mondomaine.net
monautredomaine.com</pre></div></div>

<p>
Et pour les boîtes aux lettres virtuelles :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tutu<span style="color: #000000; font-weight: bold;">@</span>mondomaine.net mondomaine.net<span style="color: #000000; font-weight: bold;">/</span>tutu<span style="color: #000000; font-weight: bold;">/</span>
toto<span style="color: #000000; font-weight: bold;">@</span>monautredomaine.com monautredomaine.com<span style="color: #000000; font-weight: bold;">/</span>toto<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>
Noter le / (slash) de fin important pour indiquer qu&#8217;il s&#8217;agit de boîtes au format Maildir.
</p>
<p>
On ajoute un alias pour par exemple rediriger le courrier de <em>toto@monautredomaine.com</em> vers l’adresse <em>tutu@mondomaine.net</em> dans <em>user_aliases</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">toto<span style="color: #000000; font-weight: bold;">@</span>monautredomaine.com tutu<span style="color: #000000; font-weight: bold;">@</span>mondomaine.net</pre></div></div>

<p>
Et pour fignoler, on redirige le courrier de root – qui arrive sous <em>/var/mail/root</em> – vers une adresse virtuelle pour que la lecture des courriers important du système soit facilité. Ceci ce fait dans le fichier <em>/etc/aliases</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root: tutu<span style="color: #000000; font-weight: bold;">@</span>mondomaine.net</pre></div></div>

<p>
Postfix ne lit pas ce genre de fichier tel quel, il faut comme pour le fichier <em>generic</em> le compiler pour créer le fichier de base de données grâce à la commande <em>postmap</em>, comme ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">postmap <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>user_mailboxes_path
postmap <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>user_aliases</pre></div></div>

<p>Les alias locaux eux se compilent avec la commande :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">newaliases</pre></div></div>

<p>Une fois les changements effectués, on recharge Postfix :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service postfix reload</span></pre></div></div>

<p>On peut désormais faire un petit essai d’envoi d’email :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># &quot;Email test&quot; | mail -s &quot;Test email root&quot; root</span></pre></div></div>

<p>
Le message doit arriver dans <em>/home/vmail/mondomaine.net/tutu/new/</em>, l’arborescence étant créée automatiquement par Postfix dès réception de l’email.<br />
A noter qu’il est préférable d’avoir un champ MX mondomaine.net dans vos zones DNS pour que le courrier soit bien acheminé.
</p>
<h4>Dovecot</h4>
<p>
Comme le dit <a title="lairdutemps.org" href="http://ll.lairdutemps.org/linux/howto/postfix?s=postfix">le site</a> sur lequel je me suis inspiré, recevoir du courrier c’est bien, pouvoir le lire c’est mieux. Pour cela, il faut installer Dovecot que l&#8217;on utilisera en serveur IMAP.
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install dovecot</span></pre></div></div>

<p>
Le fichier de configuration se situant sous <em>/etc/dovecot/dovecot.conf</em>, on l’édite comme suit :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># On veut des BAL IMAP</span>
protocols = imap
&nbsp;
<span style="color: #666666; font-style: italic;"># Chemin des les logs</span>
log_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot.log
info_log_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot-info.log
&nbsp;
<span style="color: #666666; font-style: italic;"># Je ne veux pas de SSL</span>
ssl_disable = <span style="color: #c20cb9; font-weight: bold;">yes</span>
disable_plaintext_auth = no
&nbsp;
<span style="color: #666666; font-style: italic;"># Les BAL seront au format Maildir</span>
mail_location = maildir:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n
&nbsp;
<span style="color: #666666; font-style: italic;"># Optimisations</span>
<span style="color: #007800;">dotlock_use_excl</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #007800;">maildir_copy_with_hardlinks</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Configuration de l'authentification</span>
auth_verbose = <span style="color: #c20cb9; font-weight: bold;">yes</span>
auth default <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    mechanisms = plain
    passdb passwd-file <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Chemin vers les utilisateurs dovecot (les adresses email gérées)</span>
        args = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
    userdb static <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Chemin vers les BAL</span>
        args = <span style="color: #007800;">uid</span>=vmail <span style="color: #007800;">gid</span>=vmail <span style="color: #007800;">home</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>
Maintenant il faut créer les utilisateurs (adresses emails) et les mots de passes associés pour accèder aux BAL dans le fichier <em>/etc/dovecot/passwd</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;tutu@mondomaine.net:<span style="color: #780078;">`dovecotpw -p lemotdepasse`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span></pre></div></div>

<p>On démarre Dovecot :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service dovecot start</span></pre></div></div>

<p>
Et voilà, c’est fini! Il ne reste plus qu’à le tester. On peut commencer par essayer d’accéder à une BAL en <a title="Wikipedia" href="http://fr.wikipedia.org/wiki/Telnet">telnet</a> sur le port 143 :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ telnet monhostname.mondomaine.net <span style="color: #000000;">143</span>
Trying 127.0.0.1...
Connected to monhostname.mondomaine.net.
Escape character is <span style="color: #ff0000;">'^]'</span>.
<span style="color: #000000; font-weight: bold;">*</span> OK Dovecot ready.
<span style="color: #000000;">1</span> <span style="color: #c20cb9; font-weight: bold;">login</span> tutu<span style="color: #000000; font-weight: bold;">@</span>mondomaine.net motdepasse
&nbsp;
<span style="color: #000000;">1</span> OK Logged in.
<span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">select</span> inbox
<span style="color: #000000; font-weight: bold;">*</span> FLAGS <span style="color: #7a0874; font-weight: bold;">&#40;</span>\Answered \Flagged \Deleted \Seen \Draft<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">*</span> OK <span style="color: #7a0874; font-weight: bold;">&#91;</span>PERMANENTFLAGS <span style="color: #7a0874; font-weight: bold;">&#40;</span>\Answered \Flagged \Deleted \Seen \Draft \<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> Flags permitted.
&nbsp;
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">1</span> EXISTS
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">0</span> RECENT
<span style="color: #000000; font-weight: bold;">*</span> OK <span style="color: #7a0874; font-weight: bold;">&#91;</span>UIDVALIDITY <span style="color: #000000;">1217314075</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> UIDs valid
&nbsp;
<span style="color: #000000; font-weight: bold;">*</span> OK <span style="color: #7a0874; font-weight: bold;">&#91;</span>UIDNEXT <span style="color: #000000;">15</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> Predicted next UID
<span style="color: #000000;">2</span> OK <span style="color: #7a0874; font-weight: bold;">&#91;</span>READ-WRITE<span style="color: #7a0874; font-weight: bold;">&#93;</span> Select completed.
&nbsp;
<span style="color: #000000;">3</span> list <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #000000; font-weight: bold;">*</span> LIST <span style="color: #7a0874; font-weight: bold;">&#40;</span>\HasNoChildren<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #ff0000;">&quot;Drafts&quot;</span>
<span style="color: #000000; font-weight: bold;">*</span> LIST <span style="color: #7a0874; font-weight: bold;">&#40;</span>\HasNoChildren<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #ff0000;">&quot;Sent&quot;</span>
<span style="color: #000000; font-weight: bold;">*</span> LIST <span style="color: #7a0874; font-weight: bold;">&#40;</span>\HasNoChildren<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #ff0000;">&quot;Trash&quot;</span>
<span style="color: #000000; font-weight: bold;">*</span> LIST <span style="color: #7a0874; font-weight: bold;">&#40;</span>\HasNoChildren<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #ff0000;">&quot;INBOX&quot;</span>
&nbsp;
<span style="color: #000000;">3</span> OK List completed.</pre></div></div>

<p>
Si cela fonctionne, vous pouvez essayer avec un vrai client (Thunderbird, Mail.app, Claws Mail, Outlook). Sinon, il faut aller voir d&#8217;où vient le problème dans les logs sous <em>/var/log</em> et mieux vaut lire et relire les documentations (voir ci-dessous).
</p>
<hr />
<h4>En complément :</h4>
<ul>
<li>Première partie : Serveur de messagerie simple avec Postfix et Dovecot</li>
<li>Deuxième partie : <a href="http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/" title="Postfix SASL avec Dovecot"><strong>Postfix SASL avec Dovecot</strong></a></li>
<li>Troisième partie : <a href="http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix/" title="Ajouter le support TLS à Postfix"><strong>Ajouter le support TLS à Postfix</strong></a></li>
<li><a href="http://www.postfix.org/" title="Postfix" target="_blank">http://www.postfix.org/</a></li>
<li><a href="http://www.dovecot.org/" title="Dovecot" target="_blank">http://www.dovecot.org/</a></li>
<li><a title="lairdutemps.org" href="http://ll.lairdutemps.org/linux/howto/postfix?s=postfix">lairdutemps.org</a></li>
</ul>
<hr />
<p>
Les bases de cet article à l&#8217;origine pour <a href="http://archlinux.fr/">Arch Linux</a> datent du 29 juillet 2008, c&#8217;est une sorte de re-publication un peu mise-à-jour pour Fedora et un transfert de Joomla vers WordPress.</p>
<img src="http://feeds.feedburner.com/~r/feub/werk/~4/JJbRSxQUBiA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=serveur-de-messagerie-simple-avec-postfix-et-dovecot</feedburner:origLink></item>
		<item>
		<title>Sauvegarder son compte Gmail avec getmail</title>
		<link>http://feedproxy.google.com/~r/feub/werk/~3/ScqrXqi89WY/</link>
		<comments>http://werk.feub.net/2011/05/sauvegarder-son-compte-gmail-avec-getmail/#comments</comments>
		<pubDate>Wed, 04 May 2011 14:24:21 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[fetchmail]]></category>
		<category><![CDATA[getmail]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[google apps]]></category>
		<category><![CDATA[maildir]]></category>
		<category><![CDATA[mbox]]></category>
		<category><![CDATA[sauvegarde]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=772</guid>
		<description><![CDATA[getmail est un script en python écrit par Charles Cazabon qui permet de rapatrier les courriers d&#8217;une ou plusieurs boites aux lettres d&#8217;une façon simple (mais efficace). Selon les mots de son auteur, getmail est conçu pour être sécurisé, flexible, fiable et facile d&#8217;utilisation. Il est un remplaçant potentiel de fetchmail. Ce petit tutoriel est [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/05/gmail_red.png" alt="" class="floatleft" /><a href="http://pyropus.ca/software/getmail/">getmail</a> est un script en python écrit par Charles Cazabon qui permet de rapatrier les courriers d&#8217;une ou plusieurs boites aux lettres d&#8217;une façon simple (mais efficace). Selon les mots de son auteur, getmail est conçu pour être sécurisé, flexible, fiable et facile d&#8217;utilisation. Il est un remplaçant potentiel de <a href="http://fetchmail.berlios.de/">fetchmail</a>.
</p>
<p>
Ce petit tutoriel est fait sur une distribution <a href="http://www.centos.org/">CentOS</a> et c&#8217;est la procèdure de sauvegarde que j&#8217;utilise pour mon compte Gmail (Google Apps). La boite aux lettres de destination est de type <a href="https://secure.wikimedia.org/wikipedia/fr/wiki/Maildir">Maildir</a>, c&#8217;est-à-dire que chaque courrier est dans un fichier unique contrairement à <a href="https://secure.wikimedia.org/wikipedia/fr/wiki/Mbox">Mbox</a> qui place tous les courriers dans un fichier unique.
</p>
<p><span id="more-772"></span></p>
<h4>Installation de getmail</h4>
<p>
Choisissez votre gestionnaire de paquets préféré, pour les habitués des distributions à base de Red Hat, ce sera <em>yum</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install getmail</span></pre></div></div>

<h4>Création des répertoires</h4>
<p>
Le script ne crée pas par lui-même les répertoires et fichiers nécessaires au bon fonctionnement de getmail, il faut donc les ajouter à la main. On commence par l&#8217;arborescence de type Maildir qui accueillera les emails :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> ~<span style="color: #000000; font-weight: bold;">/</span>Maildir<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>new,tmp,cur<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>
Je ne m&#8217;attarde pas sur les trois répertoires <em>cur</em>, <em>tmp</em> et <em>new</em>, c&#8217;est l&#8217;arborescence de <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Maildir#Technical_operation">fonctionnement de Maildir</a>. Ensuite, il faut créer le répertoire qui contiendra le fichier de configuration et les logs de getmail :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>.getmail
$ <span style="color: #c20cb9; font-weight: bold;">vim</span> ~<span style="color: #000000; font-weight: bold;">/</span>.getmail<span style="color: #000000; font-weight: bold;">/</span>gmailrc
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">700</span> ~<span style="color: #000000; font-weight: bold;">/</span>.getmail</pre></div></div>

<h4>Configuration</h4>
<p>
Voici mon fichier de configuration pour sauvegarder un compte <a href="http://www.google.com/apps/">Google Apps</a> en utilisant IMAP :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>retriever<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">type</span> = SimpleIMAPSSLRetriever
server = imap.gmail.com
mailboxes = <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;[Gmail]/All Mail&quot;</span>,<span style="color: #7a0874; font-weight: bold;">&#41;</span>
username = nom<span style="color: #000000; font-weight: bold;">@</span>domaine.net
password = mot_de_passe
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>destination<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">type</span> = Maildir
path = ~<span style="color: #000000; font-weight: bold;">/</span>Maildir<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>options<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #666666; font-style: italic;"># Mode verbeux</span>
<span style="color: #666666; font-style: italic;"># 0 : n'affiche que les warnings et les erreurs</span>
<span style="color: #666666; font-style: italic;"># 1 : affiche les notifications de récupération et de suppression de messages</span>
<span style="color: #666666; font-style: italic;"># 2 : toutes les actions</span>
verbose = <span style="color: #000000;">2</span>
message_log = ~<span style="color: #000000; font-weight: bold;">/</span>.getmail<span style="color: #000000; font-weight: bold;">/</span>gmail.log
&nbsp;
<span style="color: #666666; font-style: italic;"># ne récupére que les nouveaux messages</span>
<span style="color: #666666; font-style: italic;"># idéal pour de la sauvegarde régulière</span>
read_all = <span style="color: #c20cb9; font-weight: bold;">false</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># n'altère pas les messages</span>
delivered_to = <span style="color: #c20cb9; font-weight: bold;">false</span>
received = <span style="color: #c20cb9; font-weight: bold;">false</span></pre></div></div>

<h4>Lancement du script</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ getmail <span style="color: #660033;">-r</span> ~<span style="color: #000000; font-weight: bold;">/</span>.getmail<span style="color: #000000; font-weight: bold;">/</span>gmailrc</pre></div></div>

<p>
Le script commence le rapatriement des messages et les place dans l&#8217;arborescence Maildir.
</p>
<p>
<strong>Note</strong> : Google n&#8217;autorise le transfert que d&#8217;un nombre limité de messages à la fois, si votre boite aux lettres est assez importante il faut relancer cette commande plusieurs fois, car seuls les nouveaux messages sont récupérés, ou alors le faire de façon automatisée (voir ci-dessous).
</p>
<h4>Automatisation</h4>
<p>
Afin d&#8217;automatiser cette sauvegarde, un job peut être ajouté dans le <a href="https://secure.wikimedia.org/wikipedia/fr/wiki/Cron">cron</a>. L&#8217;option <em>-q</em> rend l&#8217;opération silentieuse, sauf pour les erreurs :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Le script est lancé à la 7ème minute de chaque heure ^.^</span>
<span style="color: #000000;">7</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>getmail <span style="color: #660033;">-q</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>.getmail<span style="color: #000000; font-weight: bold;">/</span>getmailrc</pre></div></div>

<img src="http://feeds.feedburner.com/~r/feub/werk/~4/ScqrXqi89WY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/05/sauvegarder-son-compte-gmail-avec-getmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://werk.feub.net/2011/05/sauvegarder-son-compte-gmail-avec-getmail/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sauvegarder-son-compte-gmail-avec-getmail</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc (Feed is rejected)
Page Caching using apc
Object Caching 820/999 objects using memcached

Served from: werk.feub.net @ 2012-02-24 10:52:10 -->

