Derniers articles http://linux.tekniko.fr Derniers articles (C) 2005-2009 PHPBoost fr PHPBoost 3 - How to : FTP over SSL http://linux.tekniko.fr/articles/articles-2-49+3-how-to-ftp-over-ssl.php http://linux.tekniko.fr/articles/articles-2-49+3-how-to-ftp-over-ssl.php Nous venons de voir comment mettre en oeuvre de façon sécurisé un serveur ftp avec <a href="http://linux.tekniko.fr/articles/articles-2-48+serveur-ftp-avec-vsftpd-2-securite-1.php">vsftpd/pam/xinetd</a>, nous allons voir maintenant, afin de nous sécuriser un peu plus, comment crypter ces échanges ftp avec <a href="http://fr.wikipedia.org/wiki/OpenSSL">OpenSSL</a>.<br /> <br /> <em>OpenSSL</em> c'est quoi ? Et bien c'est une boite à outils comme dit sur le <em>Wikipédia</em>, des bibliothèques ainsi que des commandes en ligne, et avec ces outils, nous allons pouvoir crypter nos échanges, c'est le même principe que lorsque vous achetez un produit quelconque sur le web, généralement, au moment de banquer vous devez signer un certificat de sécurité un peu obscur, puis vous passez en mode "sécurisé" (<em><a href="http://fr.wikipedia.org/wiki/Https#HTTPS">https</a></em>), a partir de la, les données qui transitent entre vous et le "site" (numéro de carte bancaire, coordonnées etc...) sont cryptées. C'est le résultat d'<em>Openssl</em> couplé au serveur <em>Apache</em>, nous, nous allons le coupler à <em>Vsftpd</em>, le principe restera le même mise à part que ce sera le protocole <em>ftp</em> qui sera crypté (ftps)et non <em><a href="http://fr.wikipedia.org/wiki/Http">http</a></em>. <br /> <br /> Ah oui, cette histoire de certificat...En quoi cela ajoute t'il une sécurité ?? Normalement, on se créer un certificat avec nos coordonnées, mail, le domaine du site..., puis on le soumet à un <a href="http://www.verisign.fr/index.html">organisme de vérification</a> qui certifiera de notre identité en signant notre certif, comme ça, le client qui va voir notre beau certificat constatera que machin l'a vérifié et il pourra donc le signer et ainsi avoir une confiance aveugle, ou presque. <br /> <br /> c'est super mais ça coute beaucoup de sous de faire signer son certificat par les gens qui vont bien... Alors comme c'est la crise, on va s'auto-certifier nos certificat, on va les signer nous même ! <br /> <br /> <span class="success"><strong>Commençons !</strong></span><br /> <br /> Nous repartons sur la configuration du <a href="http://linux.tekniko.fr/articles/articles-2-48+serveur-ftp-avec-vsftpd-2-securite-1.php">premier article</a>, donc notre serveur ftp est déjà fonctionnel, il ne reste plus qu'à installer <em>OpenSSL</em>, générer les certificats, avertir <em>vsftpd</em> du changement et enfin, configurer le client ftp pour qu'il soit sur le protocole <em>ftps</em> pour pouvoir se connecter.<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> openssl</pre></pre></div><br /> Sera nécessaire mais il est très probable qu'il soit déjà installé. Le fait qu'il soit installé ne veut pas dire qu'il ne reste qu'a ajouter deux ou trois choses. On va commencer par créer un répertoire qui contiendra deux sous répertoires, un pour la base de données des certificats que nous signerons (privé), un autre pour les demande et ceux que l'on générera (newcerts).<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>CA <span style="color: #666666; font-style: italic;"># CA pour Certificat d'Autorité.</span> <span style="color: #7a0874; font-weight: bold;">cd</span> CA <span style="color: #c20cb9; font-weight: bold;">mkdir</span> privé newcerts</pre></pre></div><br /> Jusque là rien de transcendant, créons la base de données qui accueillera les futurs certificats que nous signerons : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'01'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> serial <span style="color: #c20cb9; font-weight: bold;">touch</span> index.txt</pre></pre></div><br /> Maintenant, nous allons créer un fichier de configuration spécifique que nous agrémenterons au fur et à mesure du courant. Pour le moment, on y met que ça :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>CA<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf &nbsp; <span style="color: #666666; font-style: italic;"># OpenSSL configuration file. </span> <span style="color: #666666; font-style: italic;"># </span> &nbsp; <span style="color: #666666; font-style: italic;"># Establish working directory. </span> <span style="color: #c20cb9; font-weight: bold;">dir</span> = . &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#91;</span>Req<span style="color: #7a0874; font-weight: bold;">&#93;</span> default_bits = <span style="color: #000000;">1024</span> <span style="color: #666666; font-style: italic;"># Taille des touches </span> key.pem default_keyfile = <span style="color: #666666; font-style: italic;"># nom de clés générées </span> default_md = md5 message <span style="color: #666666; font-style: italic;"># algorithme de </span> string_mask = <span style="color: #666666; font-style: italic;"># nombstr permis caractères </span> distinguished_name = req_distinguished_name &nbsp; <span style="color: #7a0874; font-weight: bold;">&#93;</span> Req_distinguished_name <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #666666; font-style: italic;"># Nom de la variable de chaîne rapide </span> <span style="color: #666666; font-style: italic;">#---------------------- --------------------------- ------- </span> 0.organizationName = Nom organisation <span style="color: #7a0874; font-weight: bold;">&#40;</span>entreprise<span style="color: #7a0874; font-weight: bold;">&#41;</span> organizationalUnitName = Unité organisation Nom <span style="color: #7a0874; font-weight: bold;">&#40;</span>département, division<span style="color: #7a0874; font-weight: bold;">&#41;</span> emailAddress = Adresse Email emailAddress_max = <span style="color: #000000;">40</span> Nom Localité localityName = <span style="color: #7a0874; font-weight: bold;">&#40;</span>ville, district<span style="color: #7a0874; font-weight: bold;">&#41;</span> stateOrProvinceName = nom état ou la province <span style="color: #7a0874; font-weight: bold;">&#40;</span>nom complet<span style="color: #7a0874; font-weight: bold;">&#41;</span> Nom Pays countryName = <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span> letter code<span style="color: #7a0874; font-weight: bold;">&#41;</span> countryName_min = <span style="color: #000000;">2</span> countryName_max = <span style="color: #000000;">2</span> commonName = Nom commun <span style="color: #7a0874; font-weight: bold;">&#40;</span>nom hôte, IP, ou votre nom<span style="color: #7a0874; font-weight: bold;">&#41;</span> commonName_max = <span style="color: #000000;">64</span> &nbsp; <span style="color: #666666; font-style: italic;"># Les valeurs par défaut pour ce qui précède, par souci de cohérence et moins de frappe. </span> <span style="color: #666666; font-style: italic;"># Nom de la variable Valeur </span> <span style="color: #666666; font-style: italic;">#------------------------------ ------------------- ----------- </span> 0.organizationName_default = La Société échantillon localityName_default = Metropolis stateOrProvinceName_default = New York countryName_default = US &nbsp; <span style="color: #7a0874; font-weight: bold;">&#91;</span>V3_ca<span style="color: #7a0874; font-weight: bold;">&#93;</span> basicConstraints = CA: TRUE subjectKeyIdentifier = <span style="color: #7a0874; font-weight: bold;">hash</span> authorityKeyIdentifier = keyid: toujours, l<span style="color: #ff0000;">'émetteur: toujours </span></pre></pre></div><br /> Voila tout ce qu'il faut préciser pour commencer, ce fichier est modulaire, différentes sections peuvent le composer, et certaine section peuvent avoir besoin d'autres sections... Chaque section commence par un nom entre crochets, ici cest : REQ.<br /> Dans ce fichier, il n'a que la section concernant les coordonnées propre a la demande d'un certificat qui soit là mais nous pouvons des maintenant créer notre certificat racine et se l'auto-signer avec cette commande : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-x509</span> <span style="color: #660033;">-extensions</span> v3_ca <span style="color: #660033;">-keyout</span> private<span style="color: #000000; font-weight: bold;">/</span>cakey.pem <span style="color: #660033;">-out</span> cacert.pem <span style="color: #660033;">-days</span> <span style="color: #000000;">650</span> <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf</pre></pre></div><br /> Je vous invite a lire la <em><a href="http://www.delafond.org/traducmanfr/man/man1/openssl.1.html">page de man d'OpenSSL</a></em> pour plus d'infos, ici, on passe une requête pour avoir un nouveau certificat <span style="text-decoration: underline;">signable</span>, il devrait placer la certificat d'autorité dans le répertoire courant (<em>/etc/CA</em> si on est déjà dedans), celui ci sera valable 650 jours, et la clé privée qui va avec dans <em>private</em>, et il devra faire tout ça en fonction de la configuration présente dans son fichier de conf.<br /> <br /> Dors et déjà, avec notre nouveau certificat d'autorité racine (<em>cacert.pem</em>), nous pouvons créer n'importe quel nombre de "sous" certificats pour différentes applications (https, fpts, simap...). Il faut maintenant créer l'invitation à signer notre certificat, on va rajouter des paramètres au fichier de conf :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> req_extensions = v3_req</pre></pre></div><br /> A placer en dessous de la ligne <br /> distinguished_name = req_distinguished_name<br /> Ensuite, à la fin du fichier rajouter ceci : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> <span style="color: #7a0874; font-weight: bold;">&#91;</span>V3_req<span style="color: #7a0874; font-weight: bold;">&#93;</span> basicConstraints = CA: FALSE subjectKeyIdentifier = <span style="color: #7a0874; font-weight: bold;">hash</span></pre></pre></div><br /> créons cet invitation : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-nodes</span> <span style="color: #660033;">-out</span> req.pem <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf</pre></pre></div><br /> Ce processus crée deux fichiers, une clé privé key.pem et l'invitation à signer qui va avec req.pem, qu'il serait préférable de renommer si on utilise SSL sur plusieurs services.<br /> <br /> On a notre certificat d'autorité racine, on a notre invitation a signer, certifions nous en nous signant alors ! Une derniere fois, on édite le fichier de conf pour lui rajouter les choses qui vont bien, a savoir la ou il trouvera la base de données, ou est la clé privée... Ajoutons ces quelques ligne avant la section req : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span> ca <span style="color: #7a0874; font-weight: bold;">&#93;</span> default_ca = CA_default &nbsp; <span style="color: #7a0874; font-weight: bold;">&#91;</span> CA_default <span style="color: #7a0874; font-weight: bold;">&#93;</span> serial = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>serial database = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>index.txt new_certs_dir = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>newcerts certificate = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>cacert.pem private_key = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>cakey.pem default_days = <span style="color: #000000;">365</span> default_md = md5 preserve = no email_in_dn = no nameopt = default_ca certopt = default_ca policy = policy_match &nbsp; <span style="color: #7a0874; font-weight: bold;">&#91;</span> policy_match <span style="color: #7a0874; font-weight: bold;">&#93;</span> countryName = match stateOrProvinceName = match organizationName = match organizationalUnitName = optional commonName = supplied emailAddress = optional </pre></pre></div><br /> Maintenant signons le !!!<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">openssl ca <span style="color: #660033;">-out</span> cert.pem <span style="color: #660033;">-config</span> .<span style="color: #000000; font-weight: bold;">/</span>openssl.cnf <span style="color: #660033;">-infiles</span> req.pem</pre></pre></div> <br /> Nous venons de créer deux nouveau fichiers, notre certificat signé (enfin) et une copie de celui ci dans <em>newcerts.</em> Ce certificat comporte deux version, une codée, une humainement compréhensible, enlevons cette dernière pour plus de sécurité : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> cert.pem tmp.pem openssl x509 <span style="color: #660033;">-in</span> tmp.pem <span style="color: #660033;">-out</span> cert.pem </pre></pre></div><br /> L'installation du certificat et de sa clé dépend de l'application de destination, pour <em>vsftpd</em>, on va fusionner ces deux derniers :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> key.pem cert.pem <span style="color: #000000; font-weight: bold;">&gt;</span>key-cert.pem </pre></pre></div><br /> Pour finir, expliquons à <em>vsftpd</em> qu'il doit gérer le <em>SSL</em> et que les logins/passwords ainsi que tout le transite ftp, devront être cryptés, et ou se trouve le certificat et la clé <em>SSL</em>.<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd.conf &nbsp; <span style="color: #007800;">listen</span>=NO <span style="color: #007800;">anonymous_enable</span>=NO <span style="color: #007800;">local_enable</span>=YES <span style="color: #007800;">virtual_use_local_privs</span>=YES <span style="color: #007800;">write_enable</span>=YES <span style="color: #007800;">connect_from_port_20</span>=YES <span style="color: #007800;">pam_service_name</span>=vsftpd <span style="color: #007800;">guest_enable</span>=YES <span style="color: #007800;">guest_username</span>=www-data <span style="color: #007800;">user_sub_token</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$USER</span> <span style="color: #007800;">local_root</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$USER</span> <span style="color: #007800;">chroot_local_user</span>=YES <span style="color: #007800;">hide_ids</span>=YES <span style="color: #007800;">xferlog_enable</span>=YES <span style="color: #007800;">user_config_dir</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>vsftpd_user_conf &nbsp; <span style="color: #666666; font-style: italic;"># Pour le SSL</span> <span style="color: #007800;">ssl_enable</span>=YES <span style="color: #007800;">allow_anon_ssl</span>=NO <span style="color: #007800;">force_local_data_ssl</span>=NO <span style="color: #007800;">force_local_logins_ssl</span>=YES &nbsp; <span style="color: #007800;">ssl_tlsv1</span>=YES <span style="color: #007800;">ssl_sslv2</span>=YES <span style="color: #007800;">ssl_sslv3</span>=YES <span style="color: #007800;">rsa_cert_file</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>CA<span style="color: #000000; font-weight: bold;">/</span>key-cert.pem</pre></pre></div><br /> <br /> Voili voilou, on relance vsftpd et l'affaire et dans le sac. A noter que tout les clients <em>ftp</em> ne gère pas forcément le <em>ftps</em> ou <em>ftpes</em> Pour moi cela a fonctionné avec FileZilla en mode ftpes<br /> <!-- START HTML --> <div id="media"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="450" height="350" id="csSWF"> <param name="movie" value="http://linux.tekniko.fr/articles/ssl_controller.swf" /> <param name="quality" value="best" /> <param name="bgcolor" value="#1a1a1a" /> <param name="allowfullscreen" value="true" /> <param name="scale" value="showall" /> <param name="allowscriptaccess" value="always" /> <param name="flashvars" value="autostart=false&thumb=FirstFrame.png&thumbscale=45&color=0x000000,0x000000" /> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="http://linux.tekniko.fr/articles/ssl_controller.swf" width="450" height="350"> <param name="quality" value="best" /> <param name="bgcolor" value="#1a1a1a" /> <param name="allowfullscreen" value="true" /> <param name="scale" value="showall" /> <param name="allowscriptaccess" value="always" /> <param name="flashvars" value="autostart=false&thumb=FirstFrame.png&thumbscale=45&color=0x000000,0x000000" /> <!--<![endif]--> <!--[if !IE]>--> </object> <!--<![endif]--> </object> </div> <!-- END HTML --> Thu, 17 Jun 2010 18:13:01 +0200 2 - How to : VsFtpd, Xinetd et Pam http://linux.tekniko.fr/articles/articles-2-48+2-how-to-vsftpd-xinetd-et-pam.php http://linux.tekniko.fr/articles/articles-2-48+2-how-to-vsftpd-xinetd-et-pam.php ici nous allons voir brièvement comment, avec <em><a href="http://vsftpd.beasts.org/">VSFTP</a></em>, on peut se créer un "système d'hébergement", un peu comme ce que pourrait nous offrir un hébergeur comme <strong><em><a href="http://www.phpnux.com/">PHPNux</a></em></strong>, mais l'on pourrait très bien y trouver quelques utilisations internes en entreprise.<br /> <br /> Il s'agit là de monter un <a href="http://fr.wikipedia.org/wiki/Serveur_Web">serveur web</a> pour consulter des documents, et <a href="http://fr.wikipedia.org/wiki/Serveur_FTP">ftp</a> pour les manipuler. Comme ce n'est pas encore la foire au <a href="http://desencyclopedie.wikia.com/wiki/Dindon">dindons</a>, il ne faut pas que n'importe qui puisse faire n'importe quoi donc nous allons faire appel à un système d'<strong><a href="http://fr.wikipedia.org/wiki/Authentification">authentification</a></strong> pour sécuriser un peu tout cela.<br /> <br /> Bon, l'idée est lancée, il faut la mettre en oeuvre, partons sur une Debian Lenny comme système, celle du <a href="http://linux.tekniko.fr/articles/articles-2-45+le-raid-facile-sous-linux.php">Raid 1</a> par exemple, pour mémoire et pour celles et ceux qui n'auraient pas lu <a href="http://linux.tekniko.fr/articles/articles-2-45+le-raid-facile-sous-linux.php">l'article en question</a>, il s'agit d'un serveur équipé d'un système Debian Lenny, monté sur un <em>RAID 1</em> grâce à <em>mdma</em>, le tout dans VirtualBox, cette <em>VM</em> est vue comme une machine physique sur mon réseau local. Nous choisirons <a href="http://www.apache.org/">Apache</a> et consorts pour assurer la partie web, bien sur Vsftpd pour la partie ftp et <a href="http://fr.wikipedia.org/wiki/Pluggable_Authentication_Modules">Pam</a> pour s'occuper de l'authentification.<br /> <br /> <span class="success"><strong>Commençons !</strong></span><br /> <br /> On peut installer l'ensemble des composants en même temps, cependant, limitons nous à la partie web pour le moment, et installonsle serveur Apache 2 ainsi que quelques outils qui pourraient être nécessaires : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2 mysql-server php5 php5 mysql phpmyadmin</pre></pre></div><br /> Nous venons d'installer le serveur web, un <a href="http://fr.wikipedia.org/wiki/MySQL">serveur de bases de données</a> ainsi qu'un langage web très répandu en deux secondes !<br /> <br /> Il y a très peu de configuration a faire pour obtenir une page accessible depuis le réseau, cela se situe principalement au niveau du serveur Apache qu'il faut regarder un peu, c'est très facile de voir son fichier de configuration sans les commentaires et c'est bien plus rapide d'y voir quelque chose !<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>apache2.conf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">'#'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">less</span></pre></pre></div><br /> Cela nous à donné un aperçu de ce qu'il y a dans ce fichier : <br /> <span class="text_hide">Caché:</span><div class="hide" onclick="bb_hide(this)"><div class="hide2"><br /> <br /> ServerRoot "/etc/apache2"<br /> <br /> LockFile /var/lock/apache2/accept.lock<br /> <br /> PidFile ${APACHE_PID_FILE}<br /> <br /> Timeout 300<br /> <br /> KeepAlive On<br /> <br /> MaxKeepAliveRequests 100<br /> <br /> KeepAliveTimeout 15<br /> <br /> <br /> &lt;IfModule mpm_prefork_module&gt;<br /> StartServers 5<br /> MinSpareServers 5<br /> MaxSpareServers 10<br /> MaxClients 150<br /> MaxRequestsPerChild 0<br /> &lt;/IfModule&gt;<br /> <br /> &lt;IfModule mpm_worker_module&gt;<br /> StartServers 2<br /> MinSpareThreads 25<br /> MaxSpareThreads 75 <br /> ThreadLimit 64<br /> ThreadsPerChild 25<br /> MaxClients 150<br /> MaxRequestsPerChild 0<br /> &lt;/IfModule&gt;<br /> <br /> &lt;IfModule mpm_event_module&gt;<br /> StartServers 2<br /> MaxClients 150<br /> MinSpareThreads 25<br /> MaxSpareThreads 75 <br /> ThreadLimit 64<br /> ThreadsPerChild 25<br /> MaxRequestsPerChild 0<br /> &lt;/IfModule&gt;<br /> <br /> User ${APACHE_RUN_USER}<br /> Group ${APACHE_RUN_GROUP}<br /> <br /> <br /> AccessFileName .htaccess<br /> <br /> &lt;Files ~ "^\.ht"&gt;<br /> Order allow,deny<br /> Deny from all<br /> Satisfy all<br /> &lt;/Files&gt;<br /> <br /> DefaultType text/plain<br /> <br /> <br /> HostnameLookups Off<br /> <br /> ErrorLog /var/log/apache2/error.log<br /> <br /> LogLevel warn<br /> <br /> Include /etc/apache2/mods-enabled/*.load<br /> Include /etc/apache2/mods-enabled/*.conf<br /> <br /> Include /etc/apache2/httpd.conf<br /> <br /> Include /etc/apache2/ports.conf<br /> <br /> LogFormat "%v:%p %h %l %u %t \"%r\" %&gt;s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined<br /> LogFormat "%h %l %u %t \"%r\" %&gt;s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined<br /> LogFormat "%h %l %u %t \"%r\" %&gt;s %O" common<br /> LogFormat "%{Referer}i -&gt; %U" referer<br /> LogFormat "%{User-agent}i" agent<br /> <br /> CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined<br /> <br /> <br /> <br /> Include /etc/apache2/conf.d/<br /> <br /> Include /etc/apache2/sites-enabled/<br /> </div></div><br /> il faut l'éditer maintenant pour modifier quelques paramétres en prenant soin d'en garder une copie de sauvegarde avant.<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>apache2.conf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>apache2.conf-origine <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>apache2.conf</pre></pre></div><br /> Juste au dessus de la directive ServerRoot, rajouter la suivante : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">ServerName 192.168.1.141:<span style="color: #000000;">80</span></pre></pre></div><br /> Cette directive indique à apache sur quelle adresse et port il doit s'identifier lui même. 192.167.1.141 est l'adresse de la machine virtuelle, 80 le port d'écoute par défaut.<br /> Après ça, on va faire en sorte qu'Apache n'envoie pas trop de détail sur qui il est ! Cela se passe dans le fichier security. Dans ce fichier, on peut définir la quantité d'infos qu'Apache envoie à son sujet (système sur lequel il tourne par exemple).<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>conf.d<span style="color: #000000; font-weight: bold;">/</span>security</pre></pre></div><br /> Ici, on va d'abord se rendre à la ligne ou se situe la directive <em>ServerTokens</em>, on peut attribuer plusieurs niveaux à celle ci : <br /> <ul class="bb_ul"> <li class="bb_li">Full </li><li class="bb_li">OS </li><li class="bb_li">Minimal </li><li class="bb_li">Minor </li><li class="bb_li">Major </li><li class="bb_li">Prod<br /> </li></ul><br /> Chacunes désignent un niveau d'info envoyées, ici je choisis <em>Prod</em>, pour ne rien envoyer, j'ajoute : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">ServerTokens Prod</pre></pre></div><br /> Ensuite, pour ne pas envoyer le nom du serveur en lui même, juste en dessous, passons la directive <em>serverSignature</em> sur off<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">ServerSignature Off</pre></pre></div><br /> On reload la configuration dans le serveur pour prendre en compte immédiatement ces changements : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 reload</pre></pre></div><br /> <span class="success"><strong>Voila pour la partie web ! </strong></span><br /> Notre serveur est correctement configuré et prêt à accueillir de simples fichiers html statiques à afficher ou une structure de site dynamique grâce au serveur de bases de données et à <a href="http://www.phpmyadmin.net/">PHPMyadmin</a> pour administrer celles ci.<br /> <br /> On peut maintenant s'occuper de la partie ftp/authentification, qui sera le "gros morceau" du <em>howto</em> puisque nous allons être beaucoup plus exigeant que dans un <a href="http://linux.tekniko.fr/articles/articles-2-5+serveur-ftp-avec-vsftpd-1-mise-en-place.php">précédent article</a> ou j'expliquais la mise en place de <em>VSFTPD</em> dans une conf basique; Ici, l'utilisateur anonyme sera bannit !<br /> <br /> Nous allons installer le serveur ftp de façon à ce que seule une personne identifiée puisse s'y connecter, mais aussi de façon à ce que le serveur ne soit pas constamment en écoute, mais se réveille seulement lors d'un appel. Nous ferons aussi en sorte que le dossier de l'utilisateur soit la racine du (ou des si plusieurs users) site(s) web.<br /> <br /> Tout cela est possible grâce au trio <em>Vsftpd/pam/<a href="http://fr.wikipedia.org/wiki/Xinetd">xinetd</a></em>. Vsftpd pour le serveur ftp donc, Pam, qui signifie <em><a href="http://fr.wikipedia.org/wiki/Pluggable_Authentication_Modules">Pluggable Authentication Modules</a></em> offre un système d'authentification simple et très sécurisé, grâce à lui, nos utilisateurs seront listés dans un fichier bien spécifique accompagné de leurs mots de passes respectifs cryptés. Enfin xinetd s'occupera de mettre le serveur ftp en écoute quand un utilisateur se sera authentifié avec succès, puis d'inverser cet état dans le cas contraire, ainsi le serveur ne reste pas constamment en écoute et rajoute un petit plus en sécurité.<br /> <br /> Alors, pour réaliser tout cela, il nous faut installer <em>vsftpd, xinetd, apache2-utils</em> et la <em>libpam-pwdfile</em> si elle n'est pas présente.<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> vsftpd xinetd apache2-utils libpam-pwdfile</pre></pre></div><br /> On reviendra sur le pourquoi du apache2-utils...<br /> Observons la configuration par défaut de vsftpd :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd.conf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">'#'</span></pre></pre></div><br /> On peux voir que la configuration ne correspond pas vraiment a ce que l'on cherche !<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">listen</span>=YES <span style="color: #007800;">anonymous_enable</span>=NO <span style="color: #007800;">local_enable</span>=YES <span style="color: #007800;">dirmessage_enable</span>=YES <span style="color: #007800;">use_localtime</span>=YES <span style="color: #007800;">xferlog_enable</span>=YES <span style="color: #007800;">connect_from_port_20</span>=YES <span style="color: #007800;">secure_chroot_dir</span>=<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>vsftpd<span style="color: #000000; font-weight: bold;">/</span>empty <span style="color: #007800;">pam_service_name</span>=vsftpd <span style="color: #007800;">rsa_cert_file</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>vsftpd.pem</pre></pre></div><br /> Il faut changer quelque paramétres, en enlever et en rajouter de sorte qu'à la fin, il ne doit rester que cela : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#Le serveur n'écoute pas en continue.</span> <span style="color: #007800;">listen</span>=NO <span style="color: #666666; font-style: italic;">#Pas de connections anonymes.</span> <span style="color: #007800;">anonymous_enable</span>=NO <span style="color: #666666; font-style: italic;">#Connections des logins locaux acceptées</span> <span style="color: #007800;">local_enable</span>=YES <span style="color: #666666; font-style: italic;">#Les users hors système possèdent les mêmes privilèges que les locaux</span> <span style="color: #007800;">virtual_use_local_privs</span>=YES <span style="color: #666666; font-style: italic;">#On autorise les manipulations de fichiers via ftp. Au choix.</span> <span style="color: #007800;">write_enable</span>=YES <span style="color: #666666; font-style: italic;">#On autorise les connections sur le port 20.</span> <span style="color: #007800;">connect_from_port_20</span>=YES <span style="color: #666666; font-style: italic;">#Nom du service déclaré dans la configuration Pam.</span> <span style="color: #007800;">pam_service_name</span>=vsftpd <span style="color: #666666; font-style: italic;">#On autorise les connections invitées afin de les &quot;convertir&quot; vers une nouvelle identité.</span> <span style="color: #007800;">guest_enable</span>=YES <span style="color: #666666; font-style: italic;">#Puisque c'est pour manipuler du contenu web, www-data et l identité qui convient.</span> <span style="color: #007800;">guest_username</span>=www-data <span style="color: #666666; font-style: italic;">#Permet de créer des répertoires personnels à la volée en fonction du contenu de guest_username.</span> <span style="color: #666666; font-style: italic;">#Si l utilisateur est www-data, son répertoire devrait être /var/www/homes/$USER.</span> <span style="color: #666666; font-style: italic;">#Ainsi chaque guest aura son répertoire perso dans /var/www/ .</span> <span style="color: #007800;">user_sub_token</span>=<span style="color: #007800;">$USER</span> <span style="color: #666666; font-style: italic;">#Sera la racine du serveur ftp</span> <span style="color: #007800;">local_root</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$user</span> <span style="color: #666666; font-style: italic;">#On emprisonne les processus utilisateurs</span> <span style="color: #007800;">chroot_local_user</span>=YES <span style="color: #666666; font-style: italic;">#Cette option permet d'afficher TOUS les fichiers sous l identité ftp:ftp.</span> <span style="color: #666666; font-style: italic;">#Permet également de masquer le nom du serveur. </span> <span style="color: #007800;">hide_ids</span>=YES <span style="color: #666666; font-style: italic;">#On conserve une trace de toute connections ou tentative.</span> <span style="color: #007800;">xferlog_enable</span>=YES <span style="color: #666666; font-style: italic;">#On détermine ou seront les fichier de configuration de chaque utilisateur virtuel.</span> <span style="color: #007800;">user_config_dir</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>vsftpd_user_conf</pre></pre></div><br /> J'espère que mes commentaires sont suffisamment clair et explicite.<br /> <br /> Passons à l'authentification, on a prévenu <em>vsftp</em> que les utilisateurs passeraient voir Pam pour s'authentifier avant de rentrer, parce que Pam, elle est chouette, elle s'occupe d'authentifier tout un tas de services et gens si on lui demande gentiment, il n'y a qu'à voir dans <em>/etc/pam.d/</em> pour s'en rendre compte... En installant vsftpd, on a installé une configuration Pam par défaut (comprise dans le paquet). Celle ci se base sur le fichier <em>ftpusers</em> et l'existence d'un vrai user, avec un shell distant... Et c'est moche !<br /> <br /> On à installé tout à l'heure le paquet apache2-utils, et bien celui ci permet de générer des fichier passwd pour les serveurs web, mais cela fonctione aussi sur le ftp, c'est un fichier de ce type qui va héberger l'identité de nos utilisateurs sous la forme login mot-de-passe. Donc nous allons créer un fichier <em>vsftpd.passwd</em> qui va contenir un utilisateur "test" mot de passe "test".<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">htpasswd <span style="color: #660033;">-b</span> <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd.passwd <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #7a0874; font-weight: bold;">test</span></pre></pre></div><br /> Voilà notre premier utilisateur guest créé, construisons lui son répertoire personnel dans /var/www, celui ci s'appelera test, forcément.<br /> Pour créer d'autres utilisateurs, la commande sera la suivante :<br /> htpasswd /etc/vsftpd.passwd utilisateur<br /> Le mot de passe du nouvel utilisateur sera demandé. A noter que ces utilisateurs sont "virtuels", ils sont extérieur au système et qu'il faudra leurs créer un home correspondant dans /var/www.<br /> <br /> Maintenant, il nous faut créer un fichier de configuration pour cet utilisateur test, un fichier qui va le restreindre un peu et qui se nommera test lui aussi, on le créé dans <em>/etc/vsftpd/vsftpd_user_conf/ </em> et on y place ça dedans : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">nano</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>vsftpd_user_conf<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span> &nbsp; <span style="color: #007800;">anon_world_readable_only</span>=NO <span style="color: #007800;">local_root</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #007800;">write_enable</span>=YES <span style="color: #007800;">anon_upload_enable</span>=YES <span style="color: #007800;">anon_mkdir_write_enable</span>=YES <span style="color: #007800;">anon_other_write_enable</span>=YES</pre></pre></div><br /> Là, on le restreint dans son seul et unique répertoire, il ne peut pas voir le reste du monde mais il peut cependant faire "ce qu'il lui plait" dedans.<br /> <br /> Nous allons maintenant renseigner le fichier de configuration de <em>vsftpd</em> dans <em>/etc/pam.d/</em> et changer les deux lignes en dessous de <em># Standart behaviour for ftpd(8)</em>.<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Standart behaviour for ftpd(8)</span> auth required pam_pwdfile.so <span style="color: #007800;">pwdfile</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd.passwd account required pam_permit.so</pre></pre></div><br /> Ici on a indiqué que Pam trouverait les cartes d'identités des utilisateurs autorisés dans le fichier <em>vsftpd.passwd</em> généré précédemment, on lui dit aussi que la bibliothèque <em>pam_pwdfile.so</em> lui permettrait de déchiffrer les passwords et qu'ainsi elle pourra ouvrir le compte utilisateur avec la clé <em>pam_permit.so</em><br /> La fin approche, il ne reste plus qu'a indiquer au super serveur xinetd qu'il doit réveiller vsftpd en cas de demande, pour cela, il suffit d'ajouter un fichier vsftpd dans /etc/xinetd.d/ et qui décrira les conditions du service.<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>xinetd.d<span style="color: #000000; font-weight: bold;">/</span>vsftpd &nbsp; <span style="color: #666666; font-style: italic;"># Conditions pour le réveil du ftp</span> service <span style="color: #c20cb9; font-weight: bold;">ftp</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> disable = no socket_type = stream <span style="color: #7a0874; font-weight: bold;">wait</span> = no user = root server = <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>vsftpd per_source = <span style="color: #000000;">5</span> instances = <span style="color: #000000;">200</span> only_from = 192.168.1.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span> banner_fail = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vsftpd.busy_banner log_on_success += PID HOST DURATION log_on_failure += HOST <span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></pre></div><br /> Détaillons un peut toutes ces options : <br /> <ul class="bb_ul"> <li class="bb_li"><em>disable</em> : Active ou non le service demandé. </li><li class="bb_li"><em>socket_type</em> : on détermine le type de binaire qui traitera le flux. </li><li class="bb_li"><em>wait </em>: Détermine si xinetd pourra gérer plusieurs connections. </li><li class="bb_li"><em>user</em> : Identité sous laquelle le service s'exécutera. </li><li class="bb_li"><em>server</em> : Chemin vers l'exécutable. </li><li class="bb_li"><em>per_source</em> : Détermine le nombre max de connections simultanées par adresse source. </li><li class="bb_li"><em>instances</em> : La même qu'au dessus, mais pour toutes les sources. </li><li class="bb_li"><em>only_from</em> : Détermine qui peut être une source. </li><li class="bb_li"><em>banner_fail </em>: Texte renvoyé si le serveur ne répond pas. </li><li class="bb_li"><em>log_on_success</em> : Permet de spécifier les infos qui seront inscrite dans les journaux </li><li class="bb_li"><em>log_on_failure</em> : La même qu'au dessus, mais pour les échecs de connections.<br /> </li></ul><br /> <br /> Voià, a partir d'ici, il suffit de relancer tous les services concernés pour que tout soit fonctionnel. Par la suite, notre utilisateur "test" pourra uploader ces fichiers sur son espace web via ftp, ceux ci seront visible immédiatement via un navigateur internet !<br /> <br /> Tout ceci est bien chouette et un peu plus sécurisé que la normale, mais les échanges ftp sur le réseau ne le sont pas tellement, pour remédier à cela, nous allons mettre en place SSL afin de chiffrer toutes ces transactions.... Je vous montrerai cela dans la deuxième partie de cet article. Wed, 16 Jun 2010 14:00:01 +0200 1 - How to : Le RAID facile sous linux... http://linux.tekniko.fr/articles/articles-2-45+1-how-to-le-raid-facile-sous-linux.php http://linux.tekniko.fr/articles/articles-2-45+1-how-to-le-raid-facile-sous-linux.php Vous disposez <a href="http://www.roadsidescholar.com/wp-content/uploads/2007/09/old_computer.jpg">d'un petit serveur</a> à la maison, confectionné avec du vieux matos récupéré de ci de là, et configuré aux petits oignons par vos soins...<br /> <br /> L'ennuie, c'est que ce vieux matos a souvent une fâcheuse tendance à réclamer son départ à la retraite, son disque dur fatigue prétend t'il... Mais crise oblige, l'heure n'est pas encore venue, et il va falloir bosser encore un peu ! Fort heureusement, dans le monde magique <a href="http://fr.wikipedia.org/wiki/Linux">Linux</a>, il existe des solutions pour remédier à ce problème, et il y en a de très simple !<br /> <br /> <br /> Nous allons aider le serveur en lui adjoignant un deuxième disque dur afin de seconder le premier, l'aider, le remplacer au besoin...<br /> Beaucoup de technique de Scout sont dispo pour faire cela, plus ou moins onéreuse... mais c'est la crise ! Et par chance, il se trouve que je dispose d'un second vieux disque planqué derrière des fagots... Et mon ami le manchot me dit à l'oreille :<br /> <br /> <span class="notice">Et si tu utilisai ce deuxième disque pour basculer le serveur sur un <a href="http://www.commentcamarche.net/contents/protect/raid.php3"> RAID </a> ??!!</span><br /> <br /> Je ne vais pas faire de cours sur le RAID et ces différents modes, il y a suffisamment de doc sur le <a href="http://desencyclopedie.wikia.com/wiki/Lancer_de_nain">nain Ternet</a>. Nous choisirons ici le <em>RAID 1</em>, également appelé <em>Mirroring</em> ou <em>disques en miroir</em>, grâce à ce mode, les données sont écrites de manière identique sur chaque disque qui compose la grappe, que se soit en RAID matériel, pseudo matériel ou logiciel.<br /> Cela nous apportera que des bonnes choses, en voici un pitch : <br /> <br /> <ul class="bb_ul"> <li class="bb_li"><strong><span style="text-decoration: underline;">Sécurité des données accrue.</span></strong><br /> si l'un de mes deux disques tombe, le contrôleur le désactive et l'autre prends le relai de façon transparente pour l'utilisateur. Une fois le disque défectueux remplacé, le contrôleur reconstruira les données sur le nouveau disque à l'aide de celui qui est toujours en fonction. </li><li class="bb_li"><strong><span style="text-decoration: underline;">Souplesse de fonctionnement.</span></strong><br /> Les accès en lecture du système se font sur le disque le plus facilement accessible à ce moment là et les écritures de façon simultanés, ainsi n'importe quel disque soit interchangeable n'importe quand (dixit Wikipédia).<br /> </li></ul><br /> <br /> <span class="notice">Nous suivront l'exemple didactique d'un article que j'ai lu sur le Linux Mag qui traite du sujet, et dont je reproduit une grande partie des manips ici.</span><br /> <br /> <strong><span style="font-size: 15px;">Passons aux choses sérieuses !</span></strong><br /> <br /> Notre vieux serveur est une vielle machine à l'age respectable et dont la config est la suivante : <br /> <br /> CPU AMD Athlon 1800 XP (1,33 Ghz)<br /> 1,5 Go de mémoire RAM<br /> 1er disque dur : 6 Go sata<br /> 2éme disque dur : 6 Go sata<br /> Système <a href="http://www.debian.org/releases/stable/">Debian Lenny</a><br /> <br /> La solution que nous allons mettre en place notre RAID 1 est la plus simple qui soit, comme je l'ai dis plus haut, c'est la crise, j'ai donc opté pour un contrôleur RAID logiciel, c'est à dire qu'il sera géré par le système d'exploitation du serveur (Ubuntu Gnu/Linux en l'occurrence) et non par un contrôleur dédier (sur une carte) bien trop couteux.<br /> <br /> <span class="success">Faisons un petit état des lieux et des manipulations avant toutes choses : </span><br /> <span style="text-decoration: underline;"><br /> 1 =&gt; La config des disques avant le RAID</span><br /> <br /> <span class="text_code">Code TEXT :</span><div class="code"><pre style="display:inline;"><pre class="text" style="font-family:monospace;">disque 1 /dev/sda (disque d'origine) Partitions : /dev/sda1 montée sur / /dev/sda2 montée sur /boot /dev/sda3 partition de swap &nbsp; disque 2 /dev/sdb (disque que l'on va ajouter) Partitions : Vierge</pre></pre></div><br /> <br /> <span style="text-decoration: underline;">2 =&gt; Les manipulations</span><br /> <br /> A : Partitionnement du second disque<br /> B : Installation du contrôleur RAID<br /> C : Configuration du second disque et intégration dans la grappe nouvellement créée.<br /> D : Configuration et intégration du premier disque dans la grappe<br /> <br /> <strong><span style="text-decoration: underline;">État des lieux de sortie : </span></strong><br /> <br /> Config des disques avec le RAID 1 :<br /> <br /> <span class="text_code">Code TEXT :</span><div class="code"><pre style="display:inline;"><pre class="text" style="font-family:monospace;">&quot;disque&quot; RAID monté sur /dev/md Partitions : /dev/md0 monté sur / /dev/md1 monté sur /boot /dev/md2 partition de swap</pre></pre></div><br /> <br /> <br /> <strong><span style="text-decoration: underline;">A : Partitionnement du second disque</span></strong><br /> pour se faire, nous utiliserons <a href="http://www.linux-kheops.com/doc/man/manfr/man-html-0.9/man8/sfdisk.8.html">sfdisk</a>, celui ci nous permet de partitionner le second disque a l'identique du premier grâce à une simple commande ! <br /> La voici pour notre cas présent : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">sfdisk - d <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda <span style="color: #000000; font-weight: bold;">|</span> sfdisk <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb</pre></pre></div><br /> Il se peut que le terminal ronchonne un peu mais cela n'est pas important, nous pouvons vérifier la sortie de cette commande en faisant un fdisk -l et ainsi voir que notre deuxième disque est bien partitionné.<br /> <br /> <br /> <strong><span style="text-decoration: underline;">B : Installation du contrôleur RAID</span></strong><br /> Ce contrôleur sera <a href="http://www.noisette.ch/wiki/index.php/Mdadm">MDADM</a>, il est intéressant car il va nous permettre de construire notre grappe RAID 1 avec seulement un disque dur, grâce à l'option <em>missing</em>...<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mdadm</pre></pre></div><br /> <br /> puis nous chargeons le module raid1<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">modprobe raid1</pre></pre></div><br /> <br /> Nous pouvons maintenant créer notre grappe en utilisant uniquement un seul disque (/dev/sdb) !! Et ce, grâce à l'option <em>missing</em> de mdadm.<br /> Commençons :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; mdadm <span style="color: #660033;">--create</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md0 <span style="color: #660033;">--level</span>=<span style="color: #000000;">1</span> <span style="color: #660033;">--raid-disks</span>=<span style="color: #000000;">2</span> missing <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb1 mdadm <span style="color: #660033;">--create</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md1 <span style="color: #660033;">--level</span>=<span style="color: #000000;">1</span> <span style="color: #660033;">--raid-disks</span>=<span style="color: #000000;">2</span> missing <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb2 mdadm <span style="color: #660033;">--create</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md2 <span style="color: #660033;">--level</span>=<span style="color: #000000;">1</span> <span style="color: #660033;">--raid-disks</span>=<span style="color: #000000;">2</span> missing <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb3</pre></pre></div><br /> <span class="notice">Nous pouvons vérifier que notre grappe est bien créée en faisant un simple <em>cat /proc/mdstat</em></span><br /> <br /> Créons ensuite les systèmes de fichiers du <em>RAID</em>, ceux ci doivent être identique à ceux correspondant sur /dev/sda, ici c'est du ext3, l'autre partition est une partition de swap.<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; mkfs.ext3 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md0 mkfs.ext3 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md1 mkswap <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md2</pre></pre></div><br /> Pour activer notre grappe, il faut maintenant renseigner le fichier de conf du contrôleur raid (mdadm), en prenant soin de conserver une copie d'origine, non seulement par sécurité, mais aussi parce qu'il nous sera utile par la suite...<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mdadm<span style="color: #000000; font-weight: bold;">/</span>mdadm.conf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mdadm<span style="color: #000000; font-weight: bold;">/</span>mdadm.conf-origine</pre></pre></div><br /> <br /> Pour nous simplifier encore plus la vie, il y a une commande magique (glanée sur la revue <a href="http://www.gnulinuxmag.com/">Linux Magazine</a>, comme beaucoup de cet article)<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">mdadm <span style="color: #660033;">--examine</span> <span style="color: #660033;">--scan</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>mdadm<span style="color: #000000; font-weight: bold;">/</span>mdadm.conf</pre></pre></div><br /> <br /> <span class="success">Voilà ! Notre RAID 1 unijambiste est maintenant monté !</span><br /> <br /> <br /> Continuons, il faut désormais copier les données de /dev/sda sur notre <em>RAID</em> bancale (celui ci ne comprend que /dev/sdb pour le moment). Pour cela, nous allons monter une partie du <em>RAID</em> dans un dossier afin d'y copier notre futur système de fichier racine.<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; <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>md0 <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>md0 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>md0 <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>md1 <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>md1 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>md1</pre></pre></div><br /> <br /> Puis copions tout le système : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-dpRx</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>md1 <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>boot <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-dpRx</span> . <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>md0<span style="color: #000000; font-weight: bold;">/</span>boot</pre></pre></div><br /> <br /> Détaillons ces options (<a href="http://www.bash-linux.com/unix-man-cp-francais.html">man cp</a>) : <br /> <ul class="bb_ul"> <li class="bb_li">-d : Pour copier les liens symboliques en tant que tels. </li><li class="bb_li">-p : Pour conserver les attributs des fichiers (propriétaire, groupe etc...). </li><li class="bb_li">-R : Pour copier récursivement les répertoires. </li><li class="bb_li">-x : Interdit de changer de système de fichier en cours de copie, c'est pour cela qu'il faut relancer l'opération.<br /> </li></ul><br /> <br /> Préparons maintenant la futur <em>fstab</em> de notre grappe ! Il faut l'éditer dans <em>/mnt/md0</em> et remplacer les entrées <em>sda</em> par les entrées md correspondantes de sorte d'obtenir quelque chose comme ça (pour notre config à nous bien sur) :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; <span style="color: #666666; font-style: italic;"># &lt;file system&gt; &lt;mount point&gt; &lt;type&gt; &lt;options&gt; &lt;dump&gt; &lt;pass&gt;</span> proc <span style="color: #000000; font-weight: bold;">/</span>proc proc defaults <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md1 <span style="color: #000000; font-weight: bold;">/</span> ext3 relatime,<span style="color: #007800;">errors</span>=remount-ro <span style="color: #000000;">0</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md0 <span style="color: #000000; font-weight: bold;">/</span>boot ext3 defauts <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md2 none swap sw <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>scd0 <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>cdrom0 udf,iso9660 user,noauto,<span style="color: #7a0874; font-weight: bold;">exec</span>,utf8 <span style="color: #000000;">0</span> <span style="color: #000000;">0</span></pre></pre></div><br /> <br /> <br /> Après tout cela, il faut prévenir l'ami Grub que quelque chose à changer, il faut lui ajouter une entrée supplémentaire pour pouvoir booter sur le Raid... En éditant son menu avec ça, il devrait nous entendre : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>boot<span style="color: #000000; font-weight: bold;">/</span>grub<span style="color: #000000; font-weight: bold;">/</span>menu.lst</pre></pre></div><br /> <br /> Premièrement, on lui dit qu'avec la commande <strong><a href="http://www.linux-france.org/article/sys/chargeurs/ix86/grub/grub-manual-fr.html">fallback 1</a></strong> placée juste en desous du paramétre <strong><a href="http://www.linux-france.org/article/sys/chargeurs/ix86/grub/grub-manual-fr.html">defaut 0</a></strong>, si le boot sur le Raid ne fonctionne pas, il tentera de booter sur l'autre entrée par défaut, soit l'entrée "d'origine".<br /> <br /> Deuxiémement, rajoutons le noyau du Raid qui se trouve sur /dev/md1. Il suffit de recopier le premier bloc de kernel juste en dessous de celui ci, en changeant seulement l'adresse du <em>kernel root</em>, cela doit donner quelque chose comme ça :<br /> <img src="http://linux.tekniko.fr/upload/menu_grub.png" alt="" class="valign_" /><br /> on met jour de l'image initiale <strong><a href="http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Introducing-initramfs-a-new-model-for-initial-RAM-disks/">initramfs</a></strong><br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">update-initramfs <span style="color: #660033;">-u</span></pre></pre></div><br /> pour finir en installant grub sur notre second disque, qui sera notre Raid unijambiste après le prochain reboot, si tout se passe bien...<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">grub grub<span style="color: #000000; font-weight: bold;">&gt;</span> root <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd1,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> grub<span style="color: #000000; font-weight: bold;">&gt;</span> setup <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd1<span style="color: #7a0874; font-weight: bold;">&#41;</span> grub<span style="color: #000000; font-weight: bold;">&gt;</span> quit</pre></pre></div><br /> Voili voilou, à partir de là, on peut redémarrer et booter sur notre raid si tout va bien ! ....Et en choisissant la bonne entrée aussi...<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">shutdown now <span style="color: #660033;">-r</span></pre></pre></div><br /> <br /> <!-- START HTML --> <center><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="450" height="350" id="csSWF"> <param name="movie" value="http://linux.tekniko.fr/articles/re-reboot_controller.swf" /> <param name="quality" value="best" /> <param name="bgcolor" value="#1a1a1a" /> <param name="allowfullscreen" value="true" /> <param name="scale" value="showall" /> <param name="allowscriptaccess" value="always" /> <param name="flashvars" value="autostart=false&thumb=FirstFrame.png&thumbscale=45&color=transparent" /> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="http://linux.tekniko.fr/articles/re-reboot_controller.swf" width="450" height="350"> <param name="quality" value="best" /> <param name="bgcolor" value="#1a1a1a" /> <param name="allowfullscreen" value="true" /> <param name="scale" value="showall" /> <param name="allowscriptaccess" value="always" /> <param name="flashvars" value="autostart=false&thumb=FirstFrame.png&thumbscale=45&color=transparent" /> <!--<![endif]--> <!--[if !IE]>--> </object> <!--<![endif]--> </object></center> <!-- END HTML --><br /> <span class="success">Le boot sur le Raid c'est bien passé, vous avez pu voir la grappe prendre la main en se peuplant avec seulement un disque ! </span><br /> <br /> Après s'être logué, on peut voir que nous somme bien sur le Raid en vérifiant :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><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>md1 on <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">type</span> ext3 <span style="color: #7a0874; font-weight: bold;">&#40;</span>rw,realtime,<span style="color: #007800;">errors</span>=remount -ro<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md0 on <span style="color: #000000; font-weight: bold;">/</span>boot <span style="color: #7a0874; font-weight: bold;">type</span> ext3 <span style="color: #7a0874; font-weight: bold;">&#40;</span>rw<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></pre></div><br /> <br /> Il ne reste désormais plus qu'à intégrer le premier disque dur (celui qui commence à ce faire un peu vieux) dans la grappe, ainsi elle sera complète et pleinement opérationnelle.<br /> Pour bien faire les choses, il faut déclarer toutes les partitions du disque en <em>Linux raid Autodetect</em> (fd) avec la commande fdisk, option t pour changer le type, puis fd pour linux raid autodetect, et il faut le faire pour chaque partitions.<br /> Cela prend très peu de temps et après avoir fait ça, on peut basculer le disque dur ( pour mémoire, on partait de lui au début ! ) dans la grappe.<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">mdadm <span style="color: #660033;">--add</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md0 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda1 mdadm <span style="color: #660033;">--add</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda2 mdadm <span style="color: #660033;">--add</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md2 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda3</pre></pre></div><br /> A partir de ce moment là, mdadm commence a synchroniser /dev/sda a l'identique de /dev/sdb puisque tout deux forment /dev/md et l'on peut voir cette synchronisation tout simplement en tapant ceci :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>mdstat</pre></pre></div><br /> Enfin nous allons remettre le fichier de conf de mdadm à zéro, puis nous le réinitialisera avec nos nous paramètres.<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mdadm<span style="color: #000000; font-weight: bold;">/</span>mdadm.conf-origine <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mdadm<span style="color: #000000; font-weight: bold;">/</span>mdadm.conf mdadm <span style="color: #660033;">--examine</span> <span style="color: #660033;">--scan</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>mdadm<span style="color: #000000; font-weight: bold;">/</span>mdadm.conf</pre></pre></div><br /> <span class="success">Voila, nous venons de basculer notre serveur sur un RAID 1 en toute sécurité !</span><br /> Si l'on veut gagner encore un poil plus de sécu sur le boot, on peut modifier grub pour qu'il nous affiche chacun des principaux noyaux sur chacun des disques et systèmes de fichier.<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; title Debian GNU<span style="color: #000000; font-weight: bold;">/</span>linux, RAID kernel 2.6.26-<span style="color: #000000;">2</span>-<span style="color: #000000;">686</span> 1er_disque root <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd0,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> kernel <span style="color: #000000; font-weight: bold;">/</span>vmlinuz-2.6.26-<span style="color: #000000;">2</span>-<span style="color: #000000;">686</span> <span style="color: #007800;">root</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md1 ro quiet initrd <span style="color: #000000; font-weight: bold;">/</span>initrd.img-2.6.26-<span style="color: #000000;">2.686</span> &nbsp; title Debian GNU<span style="color: #000000; font-weight: bold;">/</span>linux, RAID kernel 2.6.26-<span style="color: #000000;">2</span>-<span style="color: #000000;">686</span> root <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd1,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> kernel <span style="color: #000000; font-weight: bold;">/</span>vmlinuz-2.6.26-<span style="color: #000000;">2</span>-<span style="color: #000000;">686</span> <span style="color: #007800;">root</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md1 ro quiet initrd <span style="color: #000000; font-weight: bold;">/</span>initrd.img-2.6.26-<span style="color: #000000;">2.686</span> &nbsp; title Debian GNU<span style="color: #000000; font-weight: bold;">/</span>linux, kernel 2.6.26-<span style="color: #000000;">2</span>-<span style="color: #000000;">686</span> 1er_disque root <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd0,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> kernel <span style="color: #000000; font-weight: bold;">/</span>vmlinuz-2.6.26-<span style="color: #000000;">2</span>-<span style="color: #000000;">686</span> <span style="color: #007800;">root</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda2 ro quiet initrd <span style="color: #000000; font-weight: bold;">/</span>initrd.img-2.6.26-<span style="color: #000000;">2.686</span> &nbsp; title Debian GNU<span style="color: #000000; font-weight: bold;">/</span>linux, kernel 2.6.26-<span style="color: #000000;">2</span>-<span style="color: #000000;">686</span> root <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd1,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> kernel <span style="color: #000000; font-weight: bold;">/</span>vmlinuz-2.6.26-<span style="color: #000000;">2</span>-<span style="color: #000000;">686</span> <span style="color: #007800;">root</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb2 ro quiet initrd <span style="color: #000000; font-weight: bold;">/</span>initrd.img-2.6.26-<span style="color: #000000;">2.686</span> &nbsp;</pre></pre></div><br /> <br /> Remise à jour d'initramfs :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">update-initramfs <span style="color: #660033;">-u</span></pre></pre></div><br /> <br /> The end.<br /> <br /> Sources : <br /> <br /> linux Magazine (un très bon article de Cedric Pellerin)<br /> Linux France<br /> Manuel de cp<br /> manuel de mdadm Sun, 13 Jun 2010 09:00:01 +0200 Monitoring système avec conky... http://linux.tekniko.fr/articles/articles-2-41+monitoring-systeme-avec-conky.php http://linux.tekniko.fr/articles/articles-2-41+monitoring-systeme-avec-conky.php Conky est un petit programme permettant de surveiller les constantes de son système, ainsi que d'autres choses plus ou moins futiles....<br /> <br /> Sur cet article, je ne parlerai et ne prendrai comme exemple que ma configuration personnel, si vous désirez en savoir plus sur ces autres fonctions, je vous invite à consulter les sources qui seront indiquées en bas de cette page...<br /> <br /> <br /> <br /> <span style="text-decoration: underline;"><strong>Précisions</strong></span><br /> <br /> <em>Les fichiers de configurations présentés ici tournent sur une Ubuntu 9.04 ainsi que sur une Debian Etch.</em><br /> <br /> <br /> Pour ma part, je me contente de surveiller que quelques constantes de mon cpu, de mon disque, des processus ainsi que du réseau.<br /> <br /> Voici mon fichier de configuration : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; background no update_interval <span style="color: #000000;">1.0</span> double_buffer <span style="color: #c20cb9; font-weight: bold;">yes</span> use_xft <span style="color: #c20cb9; font-weight: bold;">yes</span> override_utf8_locale xftfont Sans:<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">size</span></span>=<span style="color: #000000;">8</span> xftalpha <span style="color: #000000;">0.8</span> &nbsp; own_window <span style="color: #c20cb9; font-weight: bold;">yes</span> own_window_transparent <span style="color: #c20cb9; font-weight: bold;">yes</span> own_window_type override own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager <span style="color: #666666; font-style: italic;">#on_bottom yes</span> &nbsp; minimum_size <span style="color: #000000;">280</span> <span style="color: #000000;">5</span> maximum_width <span style="color: #000000;">220</span> draw_shades no draw_outline no draw_borders no draw_graph_borders <span style="color: #c20cb9; font-weight: bold;">yes</span> stippled_borders <span style="color: #000000;">0</span> border_margin <span style="color: #000000;">3</span> border_width <span style="color: #000000;">0</span> &nbsp; default_color black default_shade_color black default_outline_color black color1 807d7d color2 b8c0cb color3 FC8820 &nbsp; alignment middle_right gap_x <span style="color: #000000;">20</span> gap_y <span style="color: #000000;">40</span> &nbsp; no_buffers <span style="color: #c20cb9; font-weight: bold;">yes</span> &nbsp; TEXT &nbsp; &nbsp; <span style="color: #800000;">${font Ozone:style=Bold:size=10}</span> <span style="color: #800000;">${alignr}</span><span style="color: #007800;">$color</span> SYSTEME <span style="color: #007800;">$stippled_hr</span><span style="color: #800000;">${font Sans:style=Bold:pixelsize=8}</span> <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span><span style="color: #007800;">$nodename</span> - <span style="color: #007800;">$sysname</span> <span style="color: #007800;">$kernel</span> on <span style="color: #007800;">$machine</span> <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span>CPU : <span style="color: #007800;">$color</span> AMD <span style="color: #000000;">1800</span>+ <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span>Fréquence : <span style="color: #007800;">$color</span> <span style="color: #800000;">${freq_g}</span> GHz <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span>CPU Utilisé :<span style="color: #007800;">$color</span> <span style="color: #007800;">$cpu</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #800000;">${color1}</span><span style="color: #800000;">${cpugraph FFFFFF 000000}</span> &nbsp; <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span>Uptime:<span style="color: #007800;">$color</span> <span style="color: #007800;">$uptime</span> <span style="color: #800000;">${color1}</span>- Load:<span style="color: #007800;">$color</span> <span style="color: #007800;">$loadavg</span> <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span>Mémoire RAM :<span style="color: #007800;">$mem</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$memmax</span> - <span style="color: #007800;">$memperc</span><span style="color: #000000; font-weight: bold;">%</span> &nbsp; <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span>Mémoire <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span>RAM : <span style="color: #007800;">$color</span><span style="color: #007800;">$mem</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #007800;">$memmax</span> <span style="color: #007800;">$memperc</span> <span style="color: #000000; font-weight: bold;">%</span> <span style="color: #800000;">${color2}</span><span style="color: #800000;">${membar}</span> &nbsp; <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span>Utilisation <span style="color: #c20cb9; font-weight: bold;">du</span> SWAP : <span style="color: #007800;">$color</span><span style="color: #007800;">$swap</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #007800;">$swapmax</span> <span style="color: #007800;">$swapperc</span> <span style="color: #000000; font-weight: bold;">%</span> <span style="color: #800000;">${color2}</span><span style="color: #800000;">${swapbar}</span> &nbsp; &nbsp; <span style="color: #800000;">${color black}</span>Processus:<span style="color: #007800;">$alignc</span> Memory:<span style="color: #007800;">$alignr</span> Cpu Used <span style="color: #800000;">${color #e49c16}</span><span style="color: #800000;">${top name 1}</span> <span style="color: #007800;">$alignc</span> <span style="color: #800000;">${top mem 1}</span><span style="color: #800000;">${color black}</span><span style="color: #007800;">$alignr</span><span style="color: #800000;">${top cpu 1}</span> <span style="color: #800000;">${color #e49c16}</span><span style="color: #800000;">${top name 2}</span> <span style="color: #007800;">$alignc</span> <span style="color: #800000;">${top mem 2}</span><span style="color: #800000;">${color black}</span><span style="color: #007800;">$alignr</span><span style="color: #800000;">${top cpu 2}</span> <span style="color: #800000;">${color #e49c16}</span><span style="color: #800000;">${top name 3}</span> <span style="color: #007800;">$alignc</span> <span style="color: #800000;">${top mem 3}</span><span style="color: #800000;">${color black}</span><span style="color: #007800;">$alignr</span><span style="color: #800000;">${top cpu 3}</span> <span style="color: #800000;">${color #e49c16}</span><span style="color: #800000;">${top name 4}</span> <span style="color: #007800;">$alignc</span> <span style="color: #800000;">${top mem 4}</span><span style="color: #800000;">${color black}</span><span style="color: #007800;">$alignr</span><span style="color: #800000;">${top cpu 4}</span> <span style="color: #800000;">${color #e49c16}</span><span style="color: #800000;">${top name 5}</span> <span style="color: #007800;">$alignc</span> <span style="color: #800000;">${top mem 5}</span><span style="color: #800000;">${color black}</span><span style="color: #007800;">$alignr</span><span style="color: #800000;">${top cpu 5}</span> <span style="color: #800000;">${color #e49c16}</span><span style="color: #800000;">${top name 6}</span> <span style="color: #007800;">$alignc</span> <span style="color: #800000;">${top mem 6}</span><span style="color: #800000;">${color black}</span><span style="color: #007800;">$alignr</span><span style="color: #800000;">${top cpu 6}</span> <span style="color: #800000;">${color #e49c16}</span><span style="color: #800000;">${top name 7}</span> <span style="color: #007800;">$alignc</span> <span style="color: #800000;">${top mem 7}</span><span style="color: #800000;">${color black}</span><span style="color: #007800;">$alignr</span><span style="color: #800000;">${top cpu 7}</span> <span style="color: #800000;">${color #e49c16}</span><span style="color: #800000;">${top name 8}</span> <span style="color: #007800;">$alignc</span> <span style="color: #800000;">${top mem 8}</span><span style="color: #800000;">${color black}</span><span style="color: #007800;">$alignr</span><span style="color: #800000;">${top cpu 8}</span> <span style="color: #800000;">${color #e49c16}</span><span style="color: #800000;">${top name 9}</span> <span style="color: #007800;">$alignc</span> <span style="color: #800000;">${top mem 9}</span><span style="color: #800000;">${color black}</span><span style="color: #007800;">$alignr</span><span style="color: #800000;">${top cpu 9}</span> &nbsp; &nbsp; <span style="color: #800000;">${font Ozone:style=Bold:size=10}</span> <span style="color: #800000;">${alignr}</span><span style="color: #007800;">$color</span> HDD <span style="color: #007800;">$stippled_hr</span><span style="color: #800000;">${font Sans:style=Bold:pixelsize=8}</span> &nbsp; <span style="color: #800000;">${color1}</span>Linux : <span style="color: #007800;">$color</span><span style="color: #800000;">${fs_used /}</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #800000;">${fs_size /}</span> <span style="color: #007800;">$color</span><span style="color: #800000;">${fs_used_perc /}</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #800000;">${color2}</span><span style="color: #800000;">${fs_bar /}</span> &nbsp; &nbsp; <span style="color: #800000;">${font Ozone:style=Bold:size=10}</span> <span style="color: #800000;">${alignr}</span><span style="color: #007800;">$color</span> RESEAU <span style="color: #007800;">$stippled_hr</span><span style="color: #800000;">${font Sans:style=Bold:pixelsize=8}</span> <span style="color: #800000;">${alignc}</span><span style="color: #800000;">${color1}</span>IP Distante : <span style="color: #007800;">$color</span><span style="color: #800000;">${execi 60 wget -O - [url=http://ip.tupeux.com]http://ip.tupeux.com[/url] | tail}</span> &nbsp; <span style="color: #800000;">${color1}</span>Ethernet : <span style="color: #007800;">$color</span><span style="color: #800000;">${addr eth0}</span> <span style="color: #800000;">${color1}</span>Download : <span style="color: #007800;">$color</span><span style="color: #800000;">${downspeed eth0}</span> kiB<span style="color: #000000; font-weight: bold;">/</span>s <span style="color: #800000;">${alignr}</span><span style="color: #800000;">${color1}</span>Upload : <span style="color: #007800;">$color</span><span style="color: #800000;">${upspeed eth0}</span> kiB<span style="color: #000000; font-weight: bold;">/</span>s <span style="color: #800000;">${color1}</span>Total : <span style="color: #007800;">$color</span><span style="color: #800000;">${totaldown eth0}</span> <span style="color: #800000;">${alignr}</span><span style="color: #800000;">${color1}</span>Total : <span style="color: #007800;">$color</span><span style="color: #800000;">${totalup eth0}</span></pre></pre></div><br /> <br /> <br /> <br /> Ici, quelques paramètres sont important, notamment pour l'intégration au bureau, à noter que je n'utilise pas le gestionnaire Compiz, mon chipset graphique ne me le permet pas.<br /> <br /> Voici ce qu'il faut bien vérifier : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">own_window <span style="color: #c20cb9; font-weight: bold;">yes</span> <span style="color: #666666; font-style: italic;"># On dit à Conky de ne pas se mettre sur le bureau mais dans une fenêtre propre</span> own_window_type override <span style="color: #666666; font-style: italic;"># type de fenêtre &quot;maison&quot; (le type desktop convient si on n'a pas d'ombre)</span> own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager <span style="color: #666666; font-style: italic;"># définition du type</span></pre></pre></div><br /> <br /> Ces détails sont très importants<br /> <br /> J'utilise ensuite un deuxieme fichier de config, un peu fioriture, juste pour m'afficher la date, l'heure, le jour...<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">background no update_interval <span style="color: #000000;">1.0</span> double_buffer <span style="color: #c20cb9; font-weight: bold;">yes</span> &nbsp; use_xft <span style="color: #c20cb9; font-weight: bold;">yes</span> override_utf8_locale xftfont LCD:<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">size</span></span>=<span style="color: #000000;">8</span> xftalpha <span style="color: #000000;">0.8</span> &nbsp; own_window <span style="color: #c20cb9; font-weight: bold;">yes</span> own_window_transparent <span style="color: #c20cb9; font-weight: bold;">yes</span> own_window_type override own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager <span style="color: #666666; font-style: italic;">#on_bottom yes</span> &nbsp; minimum_size <span style="color: #000000;">280</span> <span style="color: #000000;">5</span> maximum_width <span style="color: #000000;">247</span> draw_shades no draw_outline no draw_borders no draw_graph_borders <span style="color: #c20cb9; font-weight: bold;">yes</span> stippled_borders <span style="color: #000000;">0</span> border_margin <span style="color: #000000;">3</span> border_width <span style="color: #000000;">0</span> &nbsp; default_color black default_shade_color black default_outline_color black color1 5B8DCF color2 8BAEE8 color3 <span style="color: #000000;">858585</span> &nbsp; alignment bottom_middle gap_x <span style="color: #000000;">0</span> gap_y <span style="color: #000000;">60</span> &nbsp; no_buffers <span style="color: #c20cb9; font-weight: bold;">yes</span> own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager &nbsp; TEXT <span style="color: #007800;">$color</span><span style="color: #800000;">${font Ozone:style=Normal:size=16}</span><span style="color: #800000;">${alignc}</span>.: <span style="color: #007800;">$color</span><span style="color: #800000;">${time %H:%M:%S}</span><span style="color: #007800;">$color</span> :. <span style="color: #800000;">${font sans:size=10}</span><span style="color: #800000;">${alignc}</span>.: <span style="color: #007800;">$color</span><span style="color: #800000;">${time %A %d %B %Y}</span><span style="color: #007800;">$color</span> :.</pre></pre></div><br /> <br /> Puis enfin un dernier m'affichant l'utilisateur connecté (des fois que j'oublie qui je suis ! ) ainsi que le temps d'uptime et la version du kernel..<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">background no update_interval <span style="color: #000000;">1.0</span> double_buffer <span style="color: #c20cb9; font-weight: bold;">yes</span> &nbsp; use_xft <span style="color: #c20cb9; font-weight: bold;">yes</span> override_utf8_locale xftfont Sans:<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">size</span></span>=<span style="color: #000000;">8</span> xftalpha <span style="color: #000000;">0.8</span> &nbsp; own_window <span style="color: #c20cb9; font-weight: bold;">yes</span> own_window_transparent <span style="color: #c20cb9; font-weight: bold;">yes</span> own_window_type override own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager on_bottom <span style="color: #c20cb9; font-weight: bold;">yes</span> &nbsp; minimum_size <span style="color: #000000;">1280</span> <span style="color: #000000;">5</span> maximum_width <span style="color: #000000;">300</span> draw_shades no draw_outline no draw_borders no draw_graph_borders <span style="color: #c20cb9; font-weight: bold;">yes</span> stippled_borders <span style="color: #000000;">0</span> border_margin <span style="color: #000000;">3</span> border_width <span style="color: #000000;">0</span> &nbsp; default_color black default_shade_color black default_outline_color black color1 807d7d color2 b8c0cb color3 FC8820 &nbsp; alignment top_middle gap_x <span style="color: #000000;">0</span> gap_y <span style="color: #000000;">40</span> &nbsp; no_buffers <span style="color: #c20cb9; font-weight: bold;">yes</span> &nbsp; TEXT <span style="color: #800000;">${font Sans:style=Bold:pixelsize=10}</span><span style="color: #800000;">${color1}</span>L<span style="color: #ff0000;">'utilisateur$color ${exec whoami} ${color1}est connecté depuis $color $uptime ${alignc}${color1}Kernel : $color$kernel </span></pre></pre></div><br /> <br /> <br /> Quelques autres paramétres important, pour le placement des différents conky sur le bureau : <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; alignment top_middle gap_x <span style="color: #000000;">0</span> gap_y <span style="color: #000000;">40</span></pre></pre></div><br /> <br /> Inutile d'apporter des précisions ? Si ? <br /> <br /> <strong>gap_x</strong> =&gt; Pour le placement horizontal (en pixel)<br /> <strong>gap_y</strong> =&gt; " " " verticale (en pixel)<br /> <strong>alignment_middle</strong> =&gt; Pour center, mais se pourrait être left ou right !<br /> <br /> Pour tester vos conky, vous pouvez ouvrir une invite de commande en tapant sur "alt+f2", ainsi, conky sera lancé en arriere plan mais s'affichera tout de même, pour le tuer, un simple "killall conky" dans une console suffit !<br /> <br /> <br /> Afin d'automatiser le lancement au debut de chaque session, je vous propose le petit script suivant : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span> <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">15</span>; conky <span style="color: #660033;">-c</span> .conkyrc1 <span style="color: #000000; font-weight: bold;">&amp;</span> conky <span style="color: #660033;">-c</span> .conkyrc2 <span style="color: #000000; font-weight: bold;">&amp;</span> conky <span style="color: #660033;">-c</span> .conkyrc</pre></pre></div><br /> <br /> Il ne vous reste plus qu'a lui donner les droit d'execution (sudo chmod 755) et le placer dans la liste des programmes a lancer au démarrage !<br /> <br /> Un petit screenshot histoire de montrer a quoi resemble les conkys avec ces config : <br /> <br /> <a href="http://www.tekniko.fr/images/Linux/Capture.png"><img src="http://www.tekniko.fr/images/Linux/Capture-mini.png" alt="" class="valign_" /></a><br /> <br /> <strong>Sources : </strong><br /> <br /> <a href="http://conky.sourceforge.net/">Le site du projet Conky</a><br /> <a href="http://doc.ubuntu-fr.org/conky">La doc sur Ubuntu</a> Tue, 04 Aug 2009 13:52:01 +0200 CurlftpFs => Son FTP en local ! http://linux.tekniko.fr/articles/articles-2-32+curlftpfs-son-ftp-en-local.php http://linux.tekniko.fr/articles/articles-2-32+curlftpfs-son-ftp-en-local.php Depuis longtemps, je rame pour le transfert de mes fichiers locaux vers mon hébergeur, l'heure été venue de trouver un autre moyen pour ce faire, histoire de simplifier les choses !<br /> <br /> Le but du jeux étant de remplacer mon traditionnel client ftp (gftp) par quelque chose de beaucoup plus simple, monter ce ftp distant comme un simple dossier dans mon répertoire personnel...<br /> <br /> Grâce a <strong><em>Curlftpfs</em></strong>, tout cela devient possible, et en plus, avec une facilité déconcertante ! Celui ci utilise le module <strong><span style="text-decoration: underline;">Fuse</span></strong> (Filesystem in USErspace) qui permet la création de système de fichier dans l'espace utilisteur <br /> <br /> Voici la configuration pour l'exercice :<br /> <br /> <ul class="bb_ul"><li class="bb_li">Un laptop sous Ubuntu Intrepid Ibex (32bit), qui se nommera laptop dans le reste de l'article)</li></ul><br /> <br /> <ul class="bb_ul"><li class="bb_li">Un serveur ftp distant bien sur, que j'appellerai mon-ftp.fr, et partant du principe qu'il n'est pas publique, login+mdp seront nécessaires, ceux ci seront : utilisateur=util, mdp=furtif</li></ul><br /> <br /> Commençons par installer <strong><em>Curlftpfs</em></strong> (celui ci est dans les dépôts)<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">laptop<span style="color: #000000; font-weight: bold;">@</span>laptop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> curlftpfs</pre></pre></div><br /> <br /> Ensuite, créons le point de montage dans notre répertoire personnel, celui ci s'appellera ftp-local<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">laptop<span style="color: #000000; font-weight: bold;">@</span>laptop:~$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> ftp-local</pre></pre></div><br /> <br /> Voila, le plus gros du boulot est fait, voyons maintenant la syntaxe à utiliser pour monter ce ftp dans notre dossier local avec <strong><em>Curlftpfs</em></strong><br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; curlftpfs <span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #000000; font-weight: bold;">//</span> adresse-du-serveur-ftp point-de-montage <span style="color: #660033;">-o</span> option<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> à utiliser</pre></pre></div><br /> <br /> L'option que nous devons utiliser étant donné que mon ftp n'est pas publique est l'option user, pour plus d'information sur la foultitude d'options disponible, faites un petit man curlftpfs dans votre console.<br /> Voici comment utiliser l'option user<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">user</span>=mon-login-ftp:mon-mot-de-passe-ftp</pre></pre></div><br /> <br /> Au finale, et pour le cas présent, la commande sera la suivante :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">laptop<span style="color: #000000; font-weight: bold;">@</span>laptop:~$ curlftpfs <span style="color: #c20cb9; font-weight: bold;">ftp</span> : <span style="color: #000000; font-weight: bold;">//</span>mon-ftp.fr ftp-local <span style="color: #660033;">-o</span> <span style="color: #007800;">user</span>=util:furtif</pre></pre></div><br /> <p style="text-align:center">*Sans les espaces entre [url=ftp://adresse-du-serveur*]ftp://adresse-du-serveur*[/url]</p><br /> <br /> Et voila, le ftp est désormais monté dans ftp-local et je peux y travailler comme s'il s'agissait d'un dossier quelconque !<br /> mon point de montage se trouvant dans mon répertoire perso, aucun droit particulier m'est nécessaire<br /> <br /> Pour démonter le ftp, il suffit simplement de taper dans une console :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">laptop<span style="color: #000000; font-weight: bold;">@</span>laptop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> fusermount <span style="color: #660033;">-u</span> ftp-local</pre></pre></div><br /> <br /> Et voila !<br /> <br /> Pour éviter de taper son mot de passe en clair dans la console, il suffit d'éditer, ou de créer, un fichier <strong>netrc</strong>, celui ci contiendra les infos nécessaire à la connexion ftp (adresse ftp, login+mdp), ce fichier doit se trouver dans le répertoire utilisateur et il doit bien évidement être caché.<br /> <br /> En avant !<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">laptop<span style="color: #000000; font-weight: bold;">@</span>laptop:~$ <span style="color: #c20cb9; font-weight: bold;">vi</span> ~<span style="color: #000000; font-weight: bold;">/</span>.netrc</pre></pre></div><br /> <br /> Ce fichier se renseigne de la manière suivante :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">machine ftp.mon-serveur.com <span style="color: #c20cb9; font-weight: bold;">login</span> USERNAME password PASSWORD</pre></pre></div><br /> <br /> Dans mon cas cela donnera :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; machine ftp.mon-ftp.fr <span style="color: #c20cb9; font-weight: bold;">login</span> util password furtif</pre></pre></div><br /> <br /> Il faut restreindre l'accès a ce fichier :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; laptop<span style="color: #000000; font-weight: bold;">@</span>laptop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> 0600 ~<span style="color: #000000; font-weight: bold;">/</span>.netrc</pre></pre></div><br /> <br /> Maintenant, il n'est plus nécessaire d'ajouter l'option user à notre ligne de commande, il suffira simplement de dire :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">laptop<span style="color: #000000; font-weight: bold;">@</span>laptop:~$ curlftpfs <span style="color: #c20cb9; font-weight: bold;">ftp</span> : <span style="color: #000000; font-weight: bold;">//</span>mon-ftp.fr ftp-local</pre></pre></div><br /> <p style="text-align:center">*Sans les espaces entre [url=ftp://adresse-du-serveur*]ftp://adresse-du-serveur*[/url]</p><br /> <br /> Avec ça, je peux maintenant monter mon ftp dans mon répertoire perso comme s'il était vraiment dedans !<br /> <br /> On peut même ajouter un petit script pour automatiser ça !<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span> <span style="color: #666666; font-style: italic;"># Script de montage de dossier ftp avec curlftpfs et fuse.</span> <span style="color: #666666; font-style: italic;"># A utiliser avec Nautilus, ou en ligne de commande :</span> <span style="color: #666666; font-style: italic;"># ./mount_ftp ~/dossier_de_montage</span> &nbsp; <span style="color: #666666; font-style: italic;">#Variables à modifier au besoin</span> <span style="color: #007800;">$FTP</span>=<span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #000000; font-weight: bold;">//</span>mon-ftp.fr <span style="color: #007800;">$LOCAL</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>util<span style="color: #000000; font-weight: bold;">/</span>ftp-local &nbsp; gksudo <span style="color: #660033;">-p</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;FTP&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> curlftpfs <span style="color: #007800;">$FTP</span> <span style="color: #007800;">$LOCAL</span> zenity <span style="color: #660033;">--info</span> <span style="color: #660033;">--text</span>=<span style="color: #ff0000;">&quot;Cliquez sur valider pour démonter&quot;</span> fusermount <span style="color: #660033;">-u</span> <span style="color: #007800;">$LOCAL</span></pre></pre></div><br /> <p style="text-align:center">*Sans les espaces entre [url=ftp://adresse-du-serveur*]ftp://adresse-du-serveur*[/url]</p> Mon, 19 Jan 2009 16:50:01 +0100 Chiffrer un répertoire avec encfs... http://linux.tekniko.fr/articles/articles-2-9+chiffrer-un-repertoire-avec-encfs.php http://linux.tekniko.fr/articles/articles-2-9+chiffrer-un-repertoire-avec-encfs.php Grâce a l'application ENCFS, vous allez pouvoir chiffrer toutes les données que vous voulez ! Le principe est simple, il y a deux répertoires, un en clair et un chiffré, on fait ce que l'on veut dans le clair et des lors qu'on le ferme, toutes ces données sont chiffrées et enfermées dans le répertoire chiffré, simple non ??<br /> <br /> Les applications nécessaire à la réalisation de ce projet sont les suivantes :<br /> <br /> * Encfs<br /> <br /> * Fuse-utils<br /> <br /> * Module-assistant<br /> <br /> <br /> <br /> Pour ce billet, j'ai fait mes test avec une Dapper version serveur, le nom de machine est virtual, et l'utilisateur virtual, les dossiers seront les suivant :<br /> <br /> * Dossier en clair : libre<br /> <br /> * Dossier chiffré : .prison<br /> <br /> <br /> <br /> Commençons par installer ce qu'il faut, a savoir encfs et fuse-utils :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> encfs fuse-utils</pre></pre></div><br /> <br /> <br /> quelques librairies seront installées en plus de ces deux paquets. Il faut ensuite rajouter le module fuse au fichier modules, qui se trouve dans le répertoire /etc (pour les incultes !), afin que celui ci soit pris en compte au démarrage, deux manières, soit on édite ce fichier manuellement, soit on le rajoute via une simple ligne de commande, étant feignant à la base, j'opte pour la deuxième solution !<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo fuse &gt;&gt; /etc/modules&quot;</span></pre></pre></div><br /> <br /> <br /> ceci fait, on charge le module a l'aide de modprobe :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> modprobe fuse</pre></pre></div><br /> <br /> <br /> Jusqu'ici tout vas bien, collons nous dans le groupe de fuse, histoire de ne pas être un inconnue a ces yeux !<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> adduser virtual fuse</pre></pre></div><br /> <br /> <br /> Vérifions que c'est bon :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;fuse&quot;</span> <span style="color: #ff0000;">&quot;/etc/group&quot;</span> fuse:x:<span style="color: #000000;">113</span>:virtual</pre></pre></div><br /> <br /> <br /> Pour le 113, cela peut varier, ne vous inquiétez pas si ce n'est pas identique !<br /> Bon, on viens de dégrossir la base, pour vérifier que nous sommes bien connu du groupe fuse, la commande "groups" dans un terminal pourra nous le confirmer. Passons au plus intéressant, la création des répertoires !!!<br /> Je rappel que le répertoire clair se nomme "libre" et que celui qui sera chiffré s' appel ".prison, nous allons utiliser la commande encfs, qui ne nécessite pas de privilège root, et qui, demande des chemins complets derrière elle.<br /> créons ces répertoire dans le home :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ encfs <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>.prison <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre</pre></pre></div><br /> <br /> <br /> Une foultitude de petites questions s'en suivent, est ce qu'il faut créer ces répertoire qui n'existe pas encore ? oui, choisir une option (ou un mode) moi je le laisse vide pour avoir un mode normal<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ encfs <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>.prison <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre Le répertoire <span style="color: #ff0000;">&quot;/home/virtual/.prison/&quot;</span> n<span style="color: #ff0000;">'existe pas. Faut-il le créer ? (y/n) y Le répertoire &quot;/home/virtual/libre&quot; n'</span>existe pas. Faut-il le créer ? <span style="color: #7a0874; font-weight: bold;">&#40;</span>y<span style="color: #000000; font-weight: bold;">/</span>n<span style="color: #7a0874; font-weight: bold;">&#41;</span> y Création <span style="color: #c20cb9; font-weight: bold;">du</span> nouveau volume encrypté. Veuillez choisir l<span style="color: #ff0000;">'une des options suivantes : entrez &quot;x&quot; pour le mode de configuration expert, entrez &quot;p&quot; pour le mode paranoïaque préconfiguré, toute autre entrée ou une ligne vide sélectionnera le mode normal. &nbsp; &nbsp; &nbsp; Configuration normale sélectionnée. &nbsp; Configuration terminée. Le système de fichier à créer a les propriétés suivantes : Chiffrement de système de fichiers &quot;ssl/blowfish&quot;, version 2:1:1 Encodage de fichier &quot;nameio/block&quot;, version 3:0:1 Taille de clé : 160 bits Taille de bloc : 512 octets Chaque fichier contient un en-tête de 8 octets avec des données IV uniques. Noms de fichier encodés à l'</span>aide <span style="color: #c20cb9; font-weight: bold;">du</span> mode de chaînage IV. &nbsp;</pre></pre></div><br /> <br /> Ensuite, entrer le mot de passe qui permettra de déverrouiller ces répertoires, il peut être différent du mot de passe de session, et c'est même mieux, si l'on veut pousser sur la sécurité !<br /> <br /> Vous devez entrer un mot de passe pour votre système de fichiers.<br /> Vous devez vous en souvenir, car il n'existe aucun mécanisme de récupération.<br /> Toutefois, le mot de passe peut être changé plus tard à l'aide d'encfsctl.<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">Nouveau mot de passe : Vérifier le mot de passe :</pre></pre></div><br /> <br /> <br /> On peut vérifier que ces répertoires sont bien monter avec un petit "cat" :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>mounts rootfs <span style="color: #000000; font-weight: bold;">/</span> rootfs rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> none <span style="color: #000000; font-weight: bold;">/</span>sys sysfs rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> none <span style="color: #000000; font-weight: bold;">/</span>proc proc rw,nodiratime <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> udev <span style="color: #000000; font-weight: bold;">/</span>dev tmpfs rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>hda1 <span style="color: #000000; font-weight: bold;">/</span> ext3 rw,<span style="color: #007800;">data</span>=ordered <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>hda1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>.static<span style="color: #000000; font-weight: bold;">/</span>dev ext3 rw,<span style="color: #007800;">data</span>=ordered <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> tmpfs <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run tmpfs rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> tmpfs <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock tmpfs rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> tmpfs <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>2.6.15-<span style="color: #000000;">51</span>-<span style="color: #000000;">386</span><span style="color: #000000; font-weight: bold;">/</span>volatile tmpfs rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> devpts <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>pts devpts rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> tmpfs <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm tmpfs rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> tmpfs <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run tmpfs rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> tmpfs <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock tmpfs rw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> encfs <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre fuse rw,nosuid,nodev,<span style="color: #007800;">user_id</span>=<span style="color: #000000;">1000</span>,<span style="color: #007800;">group_id</span>=<span style="color: #000000;">1000</span>,default_permissions <span style="color: #000000;">0</span> <span style="color: #000000;">0</span></pre></pre></div><br /> <br /> <br /> Heyyy, que vois-je a la fin ?? pas de soucis, c'est monté !<br /> <br /> Bon bah ça y est, il n'y a plus qu'a s'en servir ! Pour cela, il y a deux modes : on et off<br /> En gros, on monte ces répertoire pour y travailler, y placer ces données, et on les démonte une fois finit, ce qui vas automatiquement chiffrer les données du répertoire libre dans le répertoire .prison. C'est simplement une histoire de mount...ou plutôt de fusermount !<br /> On monte avec encfs et on démonte avec fusermount (fusermount ne sera pas un inconnu pour celles et ceux qui on lu mon billet sur sshfs...).<br /> Pour monter ces répertoire, on vas utiliser la même commande que pour les créer, sauf que cette fois, la commande vas monter et pas créer, c'est simple !<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ encfs <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>.prison <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre</pre></pre></div><br /> <br /> <br /> Hop, is good, c'est monté....Et non !!! misère que se passe t'il ?? tout allé si bien ! Et pourtant sa me renvoi ça dans la console :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">fusermount: failed to access mountpoint <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre: Permission denied Erreur de fuse. Problèmes courants : - module noyau fuse non <span style="color: #c20cb9; font-weight: bold;">install</span>é <span style="color: #7a0874; font-weight: bold;">&#40;</span>faites <span style="color: #ff0000;">&quot;modprobe fuse&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> - options invalides <span style="color: #660033;">--</span> voir le message d<span style="color: #ff0000;">'utilisation </span></pre></pre></div><br /> en fait, il s'agit du module fuse qui n'est pas vraiment bien chargé, c'est la que module-assistant intervient pour corriger cela, installons le et lançons le !<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> module-assistant</pre></pre></div><br /> <br /> Pour le lancer, il suffit de l'appeler dans la console, ensuite vient un écran avec toutes une série de choix, il faut les faire dans l'ordre suivant :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">PREPARE Configurer le système pour compiler des modules SELECT Sélectionner le module ou le paquet <span style="color: #7a0874; font-weight: bold;">source</span> à traiter <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> fuse Filesystem <span style="color: #000000; font-weight: bold;">in</span> USErspace BUILD Compiler les paquets de modules pour le noyau actif INSTALL Installer les paquets pour le noyau actif EXIT Quitter le programme</pre></pre></div><br /> <br /> Et voili voilou ! A partir de la, vous pouvez monter vos répertoires avec cette commande :<br /> <strong><p style="text-align:left"><br /> ++Sous Ubuntu 8.04 Hardy, cette opération n'est pas nécessaire, relancez seulement la sessions++</p></strong><br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ encfs <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>.prison <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre</pre></pre></div><br /> <br /> <br /> Et pour les démonter, comme ceci :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ fusermount <span style="color: #660033;">-u</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre<span style="color: #000000; font-weight: bold;">/</span></pre></pre></div><br /> <br /> <br /> Et c'est a ce moment la que les données que vous avez placés dans le répertoire libre seront chiffrées dans le répertoire .prison !<br /> Pour ce qui est d'automatiser ça, c'est très simple, vous pouvez créer deux commandes, le première s'appellera decrypt (pour monter et ouvrir les répertoires) et la deuxième encrypt pour refermer et démonter le tout.<br /> Créons ces commandes, qui se trouverons avec les autres dans le répertoire /usr/bin :<br /> <br /> <span class="text_code">Code :</span><div class="code"><code><span style="color: #000000"> virtual@virtual-desktop:~$&nbsp;sudo&nbsp;vi&nbsp;/usr/bin/decrypt</span> </code></div><br /> <br /> <br /> A l'intérieur de ce fichier, collez le texte suivant :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span> encfs <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>.prison<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre<span style="color: #000000; font-weight: bold;">/</span></pre></pre></div><br /> <br /> <br /> Puis la deuxième :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</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>encrypt</pre></pre></div><br /> <br /> <br /> Même châtiment :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span> fusermount <span style="color: #660033;">-u</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre &nbsp;</pre></pre></div><br /> <br /> Donnons les droits qui vont bien a ces commandes :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> virtual <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>decrypt <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>encrypt virtual<span style="color: #000000; font-weight: bold;">@</span>virtual-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</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>encrypt <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>decrypt &nbsp;</pre></pre></div><br /> <br /> Voila, maintenant il suffit de taper "decrypt" dans la console pour avoir accès a ces données en clair, puis de fermer avec la commande "encrypt".<br /> Je vous laisse imaginer ce que l'on pourrait faire de cette application en milieu professionnel ou certaines données doivent rester confidentiel...<br /> <br /> ATTENTION : Souvenez vous bien du mot de passe attribué a ces dossier car il n'existe pas de procédure pour les récupérer en cas de perte !<br /> <br /> Voici un petit script qui vous permettra de monter/démonter vos données très simplement et de manière graphique, il vous faudra juste modifier les variables et l'enregistrer dans le dossier /home/utilisateur/.gnome2/nautilus-scripts<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; <span style="color: #666666; font-style: italic;">#!/bin/bash</span> <span style="color: #666666; font-style: italic;"># Script de montage de dossier crypté avec encfs et fuse.</span> <span style="color: #666666; font-style: italic;"># A utiliser avec Nautilus, ou en ligne de commande :</span> <span style="color: #666666; font-style: italic;"># ./mount_enc ~/dossier_de_montage</span> &nbsp; <span style="color: #666666; font-style: italic;"># Variables à modifier : repertoire contenant les fichiers non cryptés et cryptés</span> <span style="color: #007800;">OPENFOLDER</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>libre <span style="color: #007800;">CRYPTEDFOLDER</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>virtual<span style="color: #000000; font-weight: bold;">/</span>.prison &nbsp; &nbsp; gksudo <span style="color: #660033;">-p</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Top Secret&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> encfs <span style="color: #007800;">$CRYPTEDFOLDER</span> <span style="color: #007800;">$OPENFOLDER</span> zenity <span style="color: #660033;">--info</span> <span style="color: #660033;">--text</span>=<span style="color: #ff0000;">&quot;Cliquez sur valider pour démonter&quot;</span> fusermount <span style="color: #660033;">-u</span> <span style="color: #007800;">$OPENFOLDER</span></pre></pre></div><br /> <br /> Une fois enregistré, pensez a lui donner les droit d'exécution (chmod 755), il sera désormais accessible via un clic droit sur le mulot, rien n'empêche même de se créer un lanceur perso. <br /> <br /> <br /> SOURCES :<br /> <br /> <a href="http://doc.ubuntu-fr.org/encfs"> * Ce tuto sur Ubuntu-fr, dont je me suis plus que largement inspiré...</a><br /> <br /> <a href="http://arg0.net/wiki/encfs"> * Le site Encfs</a> Sun, 09 Nov 2008 15:09:01 +0100 Monter une webradio avec Icecast et Ices2 http://linux.tekniko.fr/articles/articles-2-10+monter-une-webradio-avec-icecast-et-ices2.php http://linux.tekniko.fr/articles/articles-2-10+monter-une-webradio-avec-icecast-et-ices2.php Nous allons étudier la mise en place d'un serveur de "streaming", ou, comment monter une webradio !<br /> <br /> Un ami m'a parlé d'une webradio qu'il venait de mettre en place, faisant de la musique et étant fan de l'open sources, je me suis dis, et pourquoi n'essaierai-je pas de monter la mienne ? Histoire de m'endormir moins bête le soir <img src="http://linux.tekniko.fr/images/smileys/clindoeil.gif" alt=";)" class="smiley" /> et surtout, de pouvoir diffuser mes mix ainsi que ceux de quelques ami(e)s et ce, all over the world !<br /> <br /> Après une longue réflexion, d'environ 2 secondes, je me décide et je me lance !<br /> <br /> Pour réaliser l'opération je vais avoir besoin :<br /> <br /> * D'un serveur, celui ci enverra le flux audio au travers de la toile<br /> * D'un streamer, c'est un programme qui enverra les données audio au serveur, tout en les "ré-échantillonnant"<br /> * D'un programme fournissant une API qui permet aux applications de communiquer avec le serveur<br /> <br /> Pour le serveur, mon choix c'est porté sur Icecast, pour le streamer sur Darkice-full, celui ci accepte le format Mp3 pour l'API, j'utilise la librairie Libshout.<br /> <br /> C'est parti !<br /> <br /> Je suis sur un système Ubuntu 6.06 serveur, commençons par installer le serveur Icecast2 avec un traditionnel apt-get !<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">moi<span style="color: #000000; font-weight: bold;">@</span>mon-serveur:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> icecast2</pre></pre></div><br /> <br /> Le fichier de configuration du serveur se trouve dans le répertoire /etc/icecast2 et il est au format .XML, éditons le afin de procéder a quelques réglage, et changer le mot de passe par défaut du serveur.<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">moi<span style="color: #000000; font-weight: bold;">@</span>mon-serveur:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>icecast2<span style="color: #000000; font-weight: bold;">/</span>icecast.xml</pre></pre></div><br /> <br /> Voici ce que cela nous renvoi :<br /> <span class="text_code">Code XML :</span><div class="code"><pre style="display:inline;"><pre class="xml" style="font-family:monospace;">&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;icecast<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;limits<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;clients<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>100<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/clients<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;threadpool<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/threadpool<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;queue-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>524288<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/queue-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;client-timeout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>30<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/client-timeout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;header-timeout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>15<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/header-timeout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source-timeout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source-timeout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #808080; font-style: italic;">&lt;!-- If enabled, this will provide a burst of data when a client </span> <span style="color: #808080; font-style: italic;"> first connects, thereby significantly reducing the startup </span> <span style="color: #808080; font-style: italic;"> time for listeners that do substantial buffering. However,</span> <span style="color: #808080; font-style: italic;"> it also significantly increases latency between the source</span> <span style="color: #808080; font-style: italic;"> client and listening client. For low-latency setups, you</span> <span style="color: #808080; font-style: italic;"> might want to disable this. --&gt;</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;burst-on-connect<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/burst-on-connect<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #808080; font-style: italic;">&lt;!-- same as burst-on-connect, but this allows for being more</span> <span style="color: #808080; font-style: italic;"> specific on how much to burst. Most people won't need to</span> <span style="color: #808080; font-style: italic;"> change from the default 64k. Applies to all mountpoints --&gt;</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;burst-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>65535<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/burst-size<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/limits<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;authentication<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;">&lt;! Sources log in with username <span style="color: #ff0000;">'source'</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source-password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Le-mot-de-passe-que-vous-voulez<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source-password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;">&lt;! Relays log in username <span style="color: #ff0000;">'relay'</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;relay-password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Le-même-mot-de-passe<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/relay-password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &nbsp; <span style="color: #009900;">&lt;! Admin logs in with the username given below <span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;admin-user<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>admin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/admin-user<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;admin-password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Le-mot-de-passe-que-vous-voulez<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/admin-password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/authentication<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &nbsp; <span style="color: #009900;">&lt;! Uncomment this if you want directory listings <span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!--</span> <span style="color: #808080; font-style: italic;"> &lt;directory&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;yp-url-timeout&gt;15&lt;/yp-url-timeout&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;yp-url&gt;http://dir.xiph.org/cgi-bin/yp-cgi&lt;/yp-url&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;/directory&gt;</span> <span style="color: #808080; font-style: italic;"> --&gt;</span> &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- This is the hostname other people will use to connect to your server.</span> <span style="color: #808080; font-style: italic;"> It affects mainly the urls generated by Icecast for playlists and yp</span> <span style="color: #808080; font-style: italic;"> listings. --&gt;</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hostname<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>localhost<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hostname<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &nbsp; <span style="color: #009900;">&lt;! You can use these two if you only want a single listener <span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;">&lt;!<span style="color: #000000; font-weight: bold;">&lt;port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &gt; <span style="color: #009900;">&lt;!<span style="color: #000000; font-weight: bold;">&lt;bind-address<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>127.0.0.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bind-address<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&gt; &nbsp; <span style="color: #009900;">&lt;! You may have multiple <span style="color: #000000; font-weight: bold;">&lt;listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> elements &gt; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listen-socket<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;">&lt;! <span style="color: #000000; font-weight: bold;">&lt;bind-address<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>127.0.0.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bind-address<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &gt; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listen-socket<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #808080; font-style: italic;">&lt;!--</span> <span style="color: #808080; font-style: italic;"> &lt;listen-socket&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;port&gt;8001&lt;/port&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;/listen-socket&gt;</span> <span style="color: #808080; font-style: italic;"> --&gt;</span> &nbsp; <span style="color: #009900;">&lt;!<span style="color: #000000; font-weight: bold;">&lt;master-server<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>127.0.0.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/master-server<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&gt; <span style="color: #009900;">&lt;!<span style="color: #000000; font-weight: bold;">&lt;master-server-port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8001<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/master-server-port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&gt; <span style="color: #009900;">&lt;!<span style="color: #000000; font-weight: bold;">&lt;master-update-interval<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>120<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/master-update-interval<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&gt; <span style="color: #009900;">&lt;!<span style="color: #000000; font-weight: bold;">&lt;master-password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>hackme<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/master-password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&gt; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- setting this makes all relays on-demand unless overridden, this is</span> <span style="color: #808080; font-style: italic;"> useful for master relays which do not have &lt;relay&gt; definitions here.</span> <span style="color: #808080; font-style: italic;"> The default is 0 --&gt;</span> <span style="color: #009900;">&lt;!<span style="color: #000000; font-weight: bold;">&lt;relays-on-demand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/relays-on-demand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&gt; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!--</span> <span style="color: #808080; font-style: italic;"> &lt;relay&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;server&gt;127.0.0.1&lt;/server&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;port&gt;8001&lt;/port&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;mount&gt;/example.ogg&lt;/mount&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;local-mount&gt;/different.ogg&lt;/local-mount&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;on-demand&gt;0&lt;/on-demand&gt;</span> &nbsp; <span style="color: #808080; font-style: italic;"> &lt;relay-shoutcast-metadata&gt;0&lt;/relay-shoutcast-metadata&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;/relay&gt;</span> <span style="color: #808080; font-style: italic;"> --&gt;</span> &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- Only define a &lt;mount&gt; section if you want to use advanced options,</span> <span style="color: #808080; font-style: italic;"> like alternative usernames or passwords</span> <span style="color: #808080; font-style: italic;"> &lt;mount&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;mount-name&gt;/example-complex.ogg&lt;/mount-name&gt;</span> &nbsp; <span style="color: #808080; font-style: italic;"> &lt;username&gt;othersource&lt;/username&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;password&gt;hackmemore&lt;/password&gt;</span> &nbsp; <span style="color: #808080; font-style: italic;"> &lt;max-listeners&gt;1&lt;/max-listeners&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;dump-file&gt;/tmp/dump-example1.ogg&lt;/dump-file&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;burst-size&gt;65536&lt;/burst-size&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;fallback-mount&gt;/example2.ogg&lt;/fallback-mount&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;fallback-override&gt;1&lt;/fallback-override&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;fallback-when-full&gt;1&lt;/fallback-when-full&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;intro&gt;/example_intro.ogg&lt;/intro&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;hidden&gt;1&lt;/hidden&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;no-yp&gt;1&lt;/no-yp&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;authentication type=&quot;htpasswd&quot;&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;option name=&quot;filename&quot; value=&quot;myauth&quot;/&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;option name=&quot;allow_duplicate_users&quot; value=&quot;0&quot;/&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;/authentication&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;on-connect&gt;/home/icecast/bin/stream-start&lt;/on-connect&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;on-disconnect&gt;/home/icecast/bin/stream-stop&lt;/on-disconnect&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;/mount&gt;</span> &nbsp; <span style="color: #808080; font-style: italic;"> &lt;mount&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;mount-name&gt;/auth_example.ogg&lt;/mount-name&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;authentication type=&quot;url&quot;&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;option name=&quot;mount_add&quot; value=&quot;http://myauthserver.net/notify_mount.php&quot;/&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;option name=&quot;mount_remove&quot; value=&quot;http://myauthserver.net/notify_mount.php&quot;/&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;option name=&quot;listener_add&quot; value=&quot;http://myauthserver.net/notify_listener.php&quot;/&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;option name=&quot;listener_remove&quot; value=&quot;http://myauthserver.net/notify_listener.php&quot;/&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;/authentication&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;/mount&gt;</span> &nbsp; <span style="color: #808080; font-style: italic;"> --&gt;</span> &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileserve<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileserve<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- set the mountpoint for a shoutcast source to use, the default if not</span> <span style="color: #808080; font-style: italic;"> specified is /stream but you can change it here if an alternative is</span> <span style="color: #808080; font-style: italic;"> wanted or an extension is required</span> <span style="color: #808080; font-style: italic;"> &lt;shoutcast-mount&gt;/live.nsv&lt;/shoutcast-mount&gt;</span> <span style="color: #808080; font-style: italic;"> --&gt;</span> &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;paths<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;">&lt;! basedir is only used if chroot is enabled <span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;basedir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/usr/share/icecast2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/basedir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- Note that if &lt;chroot&gt; is turned on below, these paths must both</span> <span style="color: #808080; font-style: italic;"> be relative to the new root, not the original root --&gt;</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;logdir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/var/log/icecast2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/logdir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;webroot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/usr/share/icecast2/web<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/webroot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;adminroot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/usr/share/icecast2/admin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/adminroot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;">&lt;! <span style="color: #000000; font-weight: bold;">&lt;pidfile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/usr/share/icecast2/icecast.pid<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pidfile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &gt; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- Aliases: treat requests for 'source' path as being for 'dest' path</span> <span style="color: #808080; font-style: italic;"> May be made specific to a port or bound address using the &quot;port&quot;</span> <span style="color: #808080; font-style: italic;"> and &quot;bind-address&quot; attributes.</span> <span style="color: #808080; font-style: italic;"> --&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!--</span> <span style="color: #808080; font-style: italic;"> &lt;alias source=&quot;/foo&quot; dest=&quot;/bar&quot;/&gt;</span> <span style="color: #808080; font-style: italic;"> --&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!-- Aliases: can also be used for simple redirections as well,</span> <span style="color: #808080; font-style: italic;"> this example will redirect all requests for [url=http://server]http://server[/url]:port/ to</span> <span style="color: #808080; font-style: italic;"> the status page</span> <span style="color: #808080; font-style: italic;"> --&gt;</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;alias</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #000066;">dest</span>=<span style="color: #ff0000;">&quot;/status.xsl&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/paths<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;logging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;accesslog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>access.log<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/accesslog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;errorlog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>error.log<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/errorlog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;">&lt;! <span style="color: #000000; font-weight: bold;">&lt;playlistlog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>playlist.log<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/playlistlog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &gt; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;loglevel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/loglevel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;">&lt;! 4 Debug, 3 Info, 2 Warn, 1 Error <span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;logsize<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>10000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/logsize<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;">&lt;! Max size of a logfile <span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!-- If logarchive is enabled (1), then when logsize is reached</span> <span style="color: #808080; font-style: italic;"> the logfile will be moved to error.log.DATESTAMP,</span> <span style="color: #808080; font-style: italic;"> otherwise it will be moved to error.log.old.</span> <span style="color: #808080; font-style: italic;"> Default is non-archive mode (i.e. overwrite)</span> <span style="color: #808080; font-style: italic;"> --&gt;</span> <span style="color: #009900;">&lt;! <span style="color: #000000; font-weight: bold;">&lt;logarchive<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/logarchive<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &gt; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/logging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;security<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;chroot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/chroot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #808080; font-style: italic;">&lt;!--</span> <span style="color: #808080; font-style: italic;"> &lt;changeowner&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;user&gt;nobody&lt;/user&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;group&gt;nogroup&lt;/group&gt;</span> <span style="color: #808080; font-style: italic;"> &lt;/changeowner&gt;</span> <span style="color: #808080; font-style: italic;"> --&gt;</span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/security<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/icecast<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> &nbsp;</pre></pre></div><br /> Le XML, c'est un peu comme du HTML, ce langage s'écrit sous forme de balises, sauf que dans le XML, l'ordre des balises n'a pas d'importance.<br /> <br /> Commençons par les balises &lt;limits&gt;&lt;/limits&gt;, ce qui se trouve entre ces balises parle tout seul, je ne rentrerai pas dans le détail.<br /> <br /> Puis vient les balises &lt;authentification&gt;&lt;/authentification&gt;, c'est entre ces balises qu'il faut modifier les mots de passe par défaut et ce, avant la mise en route du serveur pour des raison évidente de sécurité !<br /> <br /> Ensuite, les balises &lt;hostname&gt;&lt;/hostname&gt;, localhost si le serveur tourne en local ou le nom de machine si le serveur diffuse sur le web.<br /> <br /> Pour configurer l'accès au flux, c'est a dire le port d'écoute du serveur, c'est entre les balise &lt;port&gt;&lt;/port&gt; que cela se passe, le port par défaut et le 8000, il n'est pas vraiment utile dans le cas présent de le changer.<br /> <br /> Voila, pour une configuration minimum et fonctionnel, reste plus qu'a préciser a init de lancer icecast2 comme un service au démarrage, pour cela, il faut modifier le fichier /etc/default/icecast2 à la ligne ENABLE=false pour la changer en ENABLE=true.<br /> <br /> Voila, le serveur est prêt et il ne reste plus qu'a le lancer avec la commande /etc/init.d/icecast2 start.<br /> <br /> Une fois le serveur lancé, pour verifier si il n'y a pas de mouche dans la soupe, avec votre navigateur préféré, rendez vous a l'adresse =&gt; <a href="http://localhost:8000.">http://localhost:8000.</a><br /> <br /> Reste plus qu'a désigner des "points de montage", ces points seront en fait des playlist...La suite tout bientôt !<br /> <br /> <strong>Edit</strong> du 15/06/2010 : Ou un de ces jours... Sun, 12 Oct 2008 15:13:01 +0200 Serveur Mandataire Squid http://linux.tekniko.fr/articles/articles-2-8+serveur-mandataire-squid.php http://linux.tekniko.fr/articles/articles-2-8+serveur-mandataire-squid.php Ce billet assez court a pour but d'expliquer de maniere simple l'installation d'un serveur mandataire (ou proxy) Squid, je ne rentrerai donc pas trop pas le détail, et pour ce qui est de éléments additionnels (SquidGuard, Dansguardian...), ils feront l'objet d'un autre billet.<br /> <br /> Squid kezako ?? Squid est une serveur mandataire, c'est lui qui se trouvera entre le navigateur et le web, c'est a dire, quand vous faite une requête vers un site, cette requête sera en fait envoyé a Squid, et c'est lui qui vas se charger d'effectuer cette requête vers ce site, il sera donc mandater par vous pour aller contacter la cible.<br /> Il peut avoir plusieurs fonctions :<br /> <br /> * cache (met en "mémoire" les pages vues afin de pourvoir les ré-afficher plus rapidement si besoin)<br /> <br /> * filtrage (utile en milieu professionnel pour éviter les surfs inutiles)<br /> <br /> <br /> <br /> Comme a l'habitude, cette installation se fait sur une Ubuntu 7.10 Gutsy Desktop.<br /> <br /> Commençons par installer Squid :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> squid</pre></pre></div><br /> <br /> <br /> <br /> Ok, Squid est installé est vous avez remarqué un "Fail" lors du démarrage, et c'est normal... Comme pour beaucoup de programmes, le fichier de configuration de Squid ce trouve dans le répertoire etc, il se nomme squid.conf et nous allons l'éditer afin d'affiner sa config.<br /> Mais avant cela, sauvegardons ce fichier :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>squid<span style="color: #000000; font-weight: bold;">/</span>squid.conf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>squid<span style="color: #000000; font-weight: bold;">/</span>squid.conf.back</pre></pre></div><br /> <br /> <br /> <br /> A partir de la, on peut modifier le fichier comme on l'entend, il suffira de faire la procédure inverse pour le restaurer.<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>squid<span style="color: #000000; font-weight: bold;">/</span>squid.conf</pre></pre></div><br /> <br /> <br /> <br /> Il faut maintenant maintenant modifier quelques directives afin de rendre notre proxy fonctionnel, car par défaut, squid refuse tout....<br /> Reperez la la directive "visible_hostname" et remplissez la de la maniere suivante :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">visible_hostname mon-nom-de-machine</pre></pre></div><br /> <br /> <br /> <br /> Ensuite, parce que vous ne voulez pas que le nom de notre système ou notre adresse ip soit inclut dans les requêtes, cherchez donc la directive "forwarded_for" qui par defaut et sur "on", modifiez la comme suit :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">forwarded_for off</pre></pre></div><br /> <br /> <br /> <br /> Après, ce qui serait bien, c'est d'avoir les messages d'erreur en français ! for that, you have to search this tag :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">error_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>squid<span style="color: #000000; font-weight: bold;">/</span>errors<span style="color: #000000; font-weight: bold;">/</span>French</pre></pre></div><br /> <br /> <br /> <br /> Bon, on y est presque, reste plus qu'a se mettre client de notre beau serveur mandataire, pour cela, cherchez la directive<br /> "#Recommended minimum configuration:"<br /> et placer ceci a la fin :<br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; acl mon-acl src 192.168.1.0<span style="color: #000000; font-weight: bold;">/</span>255.255.255.0</pre></pre></div><br /> <br /> <br /> <br /> Dans ce cas, je part du principe que cette access-list s' appel "mon-acl" et que mon réseau est 192.168.1.0/255.255.255.0, a modifier selon votre config perso.<br /> Reste plus qu'a configurer votre navigateur pour qu'il passe par Squid pour faire ces requêtes et hop ! Sun, 12 Oct 2008 15:03:01 +0200 Monter un système de fichier distant avec sshfs.... http://linux.tekniko.fr/articles/articles-2-7+monter-un-systeme-de-fichier-distant-avec-sshfs.php http://linux.tekniko.fr/articles/articles-2-7+monter-un-systeme-de-fichier-distant-avec-sshfs.php Vous disposez d'un petit serveur web a la maison, sur une autre machine que votre station de travail bien sur, et vous en avez assez de faire du ssh et du scp entre ces deux machines, et bien il existe une solution permettant de faire cela via un gestionnaire de fichier, Nautilus ou autre...donc de manière graphique grâce a sshfs*!!!<br /> *sshfs : Secure SHell File System<br /> <br /> Avantages<br /> <br /> * On conserve la sécurité lié a ssh pour les échanges sur le réseau.<br /> <br /> * Confort de gestion grâce a l'interface graphique de la machine sur laquelle on monte le système.<br /> <br /> * Ne nécessite pas de droits root pour fonctionner (sauf cas précis).<br /> <br /> <br /> Voici la config utilisée pour faire cette manipulation :<br /> <br /> <br /> =&gt; Serveur web (web1) : Ubuntu 6.06 (ip=192.168.1.100)<br /> <br /> =&gt; Station de travail (stat1) : Ubuntu 7.10 (ip-192.168.1.50)<br /> <br /> <br /> Cette article part du principe que bien évidement les paquets openssh-server, openssh-client (si on veut le faire dans les deux sens ! ) soit installés sur ces machines (ainsi que Fuse pour la machine qui vas monter le système, mais ce dernier est installé de base sur Ubuntu 7.10 me semble t-il).<br /> <br /> Commençons par un exemple simple, vous souhaitez monter le dossier personnel du serveur web (/home/web1) dans le répertoire mnt de votre station de travail (/mnt/web1).<br /> Pour ce faire, vous avez besoin d'installer sur la station, le paquet sshfs (pour Secure Shell File System), c'est partit !!<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">stat1<span style="color: #000000; font-weight: bold;">@</span>stat1:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> sshfs</pre></pre></div><br /> <br /> A partir d'ici on peut se servir de sshfs, cependant, il se peut que vous ayez l'erreur suivante :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">failed to open <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>fuse: Permission denied </pre></pre></div><br /> <br /> Le moyen de résoudre ce problème est simple, il suffit de vérifier que votre utilisateur fait bien parti du groupe Fuse, en effet, Fuse permet a un simple utilisateur de monter des systèmes de fichiers....pour plus de précisions sur Fuse, c'est par ici.<br /> Si tel n'est pas le cas, il vous faudra rajouter votre user dans le group Fuse et redémarrer la machine pour que ce changement soit pris en compte.<br /> <br /> Ok, vous avez redémarré votre machine, vous faite partit du group Fuse, ssh est installé (enfin j'espère, sinon vous avez fait ça pour rien !! )<br /> Montons donc ce répertoire ! Il faut, au préalable, créer le point de montage sur le système de fichier de stat1<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">stat1<span style="color: #000000; font-weight: bold;">@</span>stat1:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <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>web1</pre></pre></div><br /> <br /> La syntaxe a utiliser avec sshfs est la suivante :<br /> <br /> <span class="text_code">Code :</span><div class="code"><code><span style="color: #000000"> user@desktop:~$sshfs&nbsp;utilisateur-local@ip-machine:le-chemein-vers-le-dossier-a-monter&nbsp;point-de-montage</span> </code></div><br /> <br /> Dans notre cas, ça donne quelque chose comme ça :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">stat1<span style="color: #000000; font-weight: bold;">@</span>stat1:~<span style="color: #007800;">$sshfs</span> web1<span style="color: #000000; font-weight: bold;">@</span>192.168.1.100:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web1 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>web1 web1<span style="color: #000000; font-weight: bold;">@</span>192.168.1.00<span style="color: #ff0000;">'s password : stat1@stat1:~$</span></pre></pre></div><br /> <br /> Votre mot de passe inscrit et validé, n'attendez pas de message de congratulation, vous n'aurez de réponse que si il y a une erreur si il n'y en a pas, vous pouvez de ce pas ouvrir votre gestionnaire de fichier et aller au point de montage, vous y trouverez le graal....<br /> <br /> Maintenant pour démonter ce système de fichier, nous allons utiliser Fuse...et oui, c'est grâce a lui qu'on peut monter un système en tant que simple utilisateur ! Voici la syntaxe a utiliser :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>desktop:~$ fusermount <span style="color: #660033;">-u</span> chemin-vers-point-de-montage</pre></pre></div><br /> <br /> donc<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">stat1<span style="color: #000000; font-weight: bold;">@</span>stat1:~$ fusermount <span style="color: #660033;">-u</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>tmp</pre></pre></div><br /> <br /> Il est également possible, si vous montez ce système régulièrement, d'éditer le fichier fstab afin d'y ajouter ce point de montage.Supposons que vous ayez ce point : /mnt/web1, cela donnerait la ligne suivantes :<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">sshfs<span style="color: #666666; font-style: italic;">#web1@192.168.1.100:/home/web1 /mnt/web1 fuse user,rw,uid=1000,gid=1000 0 0</span></pre></pre></div><br /> <br /> Et voila ! vous savez désormais monter un système de fichier distant sur votre propre machine, je vous laisse imaginer les avantage que l'on peut en tirer, surtout pour les réfractaires a la ligne de commande mais qui veulent conserver une certaine sécurité...heureusement, ssh est la ! Sun, 12 Oct 2008 15:00:01 +0200 Configurer son firewall Netfilter avec Iptables http://linux.tekniko.fr/articles/articles-2-6+configurer-son-firewall-netfilter-avec-iptables.php http://linux.tekniko.fr/articles/articles-2-6+configurer-son-firewall-netfilter-avec-iptables.php Voici un petit passage du site d'Olivier Allard-Jacquin que j'ai adoré : <br /> <br /> <br /> <span class="text_blockquote">Citation:</span><div class="blockquote">C'est juste une petite remarque auquel j'invite l'utilisateur de Windows® à réfléchir quelques secondes. Qu'est-ce qui vous prouve que toutes les trames IP qui rentrent ou qui sortent de votre Windows® passent bien par la validation du firewall que vous avez installé ? Le code source de Windows® ? Vous l'avez vu ? La belle affaire : Même si c'est le cas, je vous rappelle que vous avez un accord de non divulgation qui vous interdit de parler de ce que vous avez pu y trouver...</div><br /> <br /> <br /> <em>Netfilter</em> est un module firewall directement implémenté dans le noyau LinuX, il est l'un des plus puissant du marché et ça configuration, bien qu'elle ai l'air ardue est en faite simple, du moins pour une config de base, a savoir qu'avec Netfilter on peut faire des choses absolument énorme, du routage, du bridge (switch ethernet, on parle dans ce cas la de "bridge firewallant") etc...<br /> <br /> C'est un firewall de type "modulaire", enfin je le vois comme ça étant donné qu'il se decompose en plusieurs tables, <strong>filter</strong>, <strong>nat</strong> et <strong>mangle </strong>mais pour une station simple, nous n'utiliserons que la table filter pour commencer puis nous verrons plus tard comment appliquer ce firewall sur un serveur web par exemple.<br /> <br /> Le principe de fonctionnement est le suivant : ''Netfilter'' installe des ''hooks'' (crochets) spécifique a chaque protocole réseau et les chaînes que nous allons créer seront inscrite sur chacune des tables désignées, dans notre cas la table filter, pour vulgariser un peu, imaginons un barrage hydro-électrique, le lac en amont serait le net, ''Netfilter'' le barrage et le petit ruisseau qui en découle notre machine, maintenant imaginons que le lac est hyper pollué, qu'il y a du plombs et des matières radioactives dedans, bien sur on ne veut pas que cette pollution arrive jusqu'au petit ruisseau qui coule en bas du jardin et pour ce faire, on vas installer des filtres sur le barrage et chacun de ces filtres aura une fonction précise pour arrêter une pollution précise, le ''hook'' sera le filtre et sa fonction une chaîne ! c'est plus simple a digérer comme ça !<br /> <br /> <strong><br /> Attention</strong> : Toutes les règles ''iptables'' sont purgées a l'extinction de la machine, il faut donc faire un script qui s'exécutera au démarrage....<br /> <br /> <br /> Comme d'habitude, nous créons notre barrage sur une Ubuntu 7.10, a noter pour les utilisateurs de LinuX Mint, ''iptables'' est déjà installé ! <br /> <br /> Commençons par installer ''iptables'', c'est "l'application" qui permet de configurer Netfilter.<br /> <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> iptables</pre></pre></div><br /> <br /> ou encore <br /> <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-<span style="color: #007800;">$sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> iptables</pre></pre></div><br /> <br /> Il semblerait qu'Aptitude gère mieux les dépendances....A vérifier !<br /> Et hop c'est fait, me voila invincible ! Ca serait magnifique et chiant à la fois puisqu'il n'y aurait rien a faire, heureusement pour nous ça n'est pas le cas, vérifions ensemble qu'elles sont les règles en vigueurs par défaut après l'install d'''iptables'', pour ce faire il y a une commande très simple qui vas lister les règles attribuées, il s'agit de : <br /> <br /> <em>sudo iptables -L</em><br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-<span style="color: #007800;">$sudo</span> iptables <span style="color: #660033;">-L</span></pre></pre></div><br /> <br /> ce qui nous renvoit : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> Chain INPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT<span style="color: #7a0874; font-weight: bold;">&#41;</span> target prot opt <span style="color: #7a0874; font-weight: bold;">source</span> destination &nbsp; Chain FORWARD <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT<span style="color: #7a0874; font-weight: bold;">&#41;</span> target prot opt <span style="color: #7a0874; font-weight: bold;">source</span> destination &nbsp; Chain OUTPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT<span style="color: #7a0874; font-weight: bold;">&#41;</span> target prot opt <span style="color: #7a0874; font-weight: bold;">source</span> destination</pre></pre></div><br /> <br /> Et oui, par défaut il n'y a aucune règles, tous passe sans soucis ! c'est bien parce que rien ne bloque et pas bien parce que justement, rien n'est bloqué !! Rapellons nous que notre cas est une station isolée, donc les seules chaînes qui nous intéressent sont les chaînes INPUT et OUTPUT.<br /> <br /> Et oui, nous on veut juste un accès au Web donc la chaîne FORWARD (routage...) ne nous intéresse pas !<br /> Deux commandes sont importante si vous aviez déjà installé ''iptables'', ou si vous vous éte planté : <br /> <br /> <strong> sudo iptables -F<br /> sudo iptables -X</strong><br /> <br /> Ces deux commande permettent de réinitialiser une chaîne sélectionnée (-F) d'un utilisateur donné (-X), pour plus de renseignement sur toutes les options de la commande ''iptables'', je vous invite a consulter le man ''iptables'' en tapant dans votre terminal : man ''iptables'' ou simplement en lisant cette <a href="http://jp.barralis.com/linux-man/man8/iptables.8.php">page</a>.<br /> Bon, et si nous nous attaquions au vif du sujet ?! Parce qu'elle n'est toujours pas protégée ma station et si vous glandez trops je vais faire appel a quelqu'un d'autre !<br /> Premières notions importante : faire attention a l'ordre dans lequel on insère ces règles, parce que si on dit en premier "j'accepte une connexion sortante a destination du Web" et que par la suite on insère " je bloque tout autre trafic entrant ou sortant" et bien c'est simple, ''Netfilter'' vas lire nos règles dans l'ordre qu'on lui a donné ! donc au départ oui il vas accepter nos connexion au net mais puisqu'après on lui dit de tout bloquer, que ce soit entrant ou sortant, et bien ya rien qui passera, logique non ?<br /> <br /> Et si on créé une variable afin que notre futur script puisse s'appliquer un peu partout sans trop de soucis ?<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> <span style="color: #007800;">NET</span>=eth0</pre></pre></div><br /> <br /> Comme ça, plus besoin de modifier le nom de notre interface a chaque ligne dans le cas ou ce script serve sur plusieurs machines, il y aura seulement la variable NET= a changer si c'est nécessaire !<br /> <br /> C'est partit, montons notre barrage de police ! oui, se sont les ''Policy'' par défaut de chaque chaîne que nous allons éditer, c'est a dire le comportement de base de chaque chaîne et ce, une par une !<br /> La syntaxe est la suivante : <br /> <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> iptables <span style="color: #660033;">-table</span> <span style="color: #660033;">-option</span> chaîne action-a-effectuer-sur-les-paquets</pre></pre></div><br /> <br /> Nous utiliseront l'option -P pour dire a ''iptables'' que se sont les comportement par défaut de chaque chaîne que nous voulons modifier donc voici ce que cela donne : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-P</span> INPUT DROP</pre></pre></div><br /> puis<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-P</span> FORWARD DROP</pre></pre></div><br /> et enfin <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-P</span> OUTPUT ACCEPT</pre></pre></div><br /> <br /> Et hop, voila, la il y a plus rien qui rentre et tout peut sortir ! Et c'est a partir de LA qu'on vas définir ce qu'on autorise et ce qu'on interdit ! c'est magique non ? Alors occupons nous de notre connexion internet, j'ai envis de surfer la !<br /> Voici la syntaxe a utiliser pour insérer une règle dans une chaîne : <br /> <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-table</span> <span style="color: #660033;">-option</span> chaîne-cible <span style="color: #660033;">-interface</span> <span style="color: #660033;">-option</span> protocole <span style="color: #660033;">-option</span> action-sur-les-paquets</pre></pre></div><br /> <br /> Commençons par autoriser les connexions de l'interface de loopback : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT</pre></pre></div><br /> Autorisons le ping : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-j</span> ACC</pre></pre></div>EPT<br /> Comme on dit : Ca, c'est fait !<br /> <br /> Et pour un accès Web, insérons la règle suivante dans la chaîne INPUT : <br /> <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> RELATED,ESTABLISHED <span style="color: #660033;">-j</span> ACCEPT</pre></pre></div><br /> <br /> La je viens de dire a ''Netfilter'' que je voulais qu'il accepte les connexions deja etablie ou relatives a une connexion établie sur eth0, c'est simple non ? Et pour vérifier que ma règle est bien inscrite dans la chaîne INPUT, il suffit de taper un petit iptable -L, l'option -L dit a ''iptables'' de Lister !<br /> Maintenant histoire de sécuriser un peu plus mon barrage et colmater les fissures, je vais dire a ''Netfilter'' que si une personne souhaiterai rentrer chez moi sans ma permission express, elle se fera purement et simplement bouler, sans doute parce qu'elle a des basket.....<br /> La syntaxe est quasiment la même que pour dire qu'il n'y a que le type a qui je demande qui peut me répondre.<br /> Toutes connexions initialisées depuis le net a destination de chez moi et que je n'ai pas demandé sera rejetées ! malin non ? Puisque l'on ne peut mettre REJECT comme politique par défaut, nous allons mettre en place une "règle par défaut" pour LA chaîne INPUT : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-j</span> REJECT</pre></pre></div><br /> <br /> Tout ça c'est bien chouette mais c'est dommage que cela soit perdu au prochain redémarrage de la machine, créons un petit script pour automatiser ces règles et plaçons celui ci correctement afin qu'il soit pris en compte des le démarrage. Éditons un fichier texte dans lequel on vas placer toutes ces commandes : <br /> <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> iptables-rules.sh</pre></pre></div><br /> <br /> plaçons toutes ces commandes : <br /> <br /> <br /> <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; <span style="color: #666666; font-style: italic;">#!/bin/bash__</span> <span style="color: #666666; font-style: italic;"># Script qui démarre les règles de filtrage &quot;iptables&quot;</span> <span style="color: #666666; font-style: italic;"># Creation d'une variable pour l'interface réseau</span> <span style="color: #666666; font-style: italic;">########################################################</span> <span style="color: #007800;">NET</span>=eth0 &nbsp; <span style="color: #666666; font-style: italic;"># REMISE à ZERO des règles de filtrage</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-F</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-X</span> &nbsp; <span style="color: #666666; font-style: italic;"># DEBUT des &quot;politiques par défaut&quot;</span> <span style="color: #666666; font-style: italic;"># Je veux que les connexions entrantes soient bloquées par défaut</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-P</span> INPUT DROP &nbsp; <span style="color: #666666; font-style: italic;"># Je veux que les connexions destinées à être forwardées</span> <span style="color: #666666; font-style: italic;"># soient bloquées par défaut</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-P</span> FORWARD DROP &nbsp; <span style="color: #666666; font-style: italic;"># Je veux que les connexions sortantes soient acceptées par défaut</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-P</span> OUTPUT ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># FIN des &quot;politiques par défaut</span> <span style="color: #666666; font-style: italic;"># DEBUT des règles de filtrage</span> <span style="color: #666666; font-style: italic;"># Pas de filtrage sur l'interface de &quot;loopback&quot;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># J'accepte le protocole ICMP (le &quot;ping&quot;)</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># J'accepte les packets entrants relatifs à des connexions déjà établie</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> RELATED,ESTABLISHED <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># La règle par défaut pour la chaine INPUT devient &quot;REJECT</span> <span style="color: #666666; font-style: italic;"># (il n'est pas possible de mettre REJECT comme politique par défaut)</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-j</span> REJECT &nbsp; <span style="color: #666666; font-style: italic;"># FIN des règles de filtrage</span> &nbsp;</pre></pre></div><br /> <br /> Et voili voilou, pour le placer au démarrage, comme vous le sentez, via l'interface graphique ou en ligne de commande en lui attribuant avant les droit d'exécution : <br /> <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> iptables-rules.sh</pre></pre></div><br /> <br /> Ensuite il faut placer ce fichier dans le répertoire /etc/init.d et dire a la machine qu'il faut qu'elle prenne en compte ce script : <br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;"> moi<span style="color: #000000; font-weight: bold;">@</span>ma-machine:-$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> update-rc.d iptable-rules.sh defaults</pre></pre></div><br /> Au prochain redémarrage, un simple petit sudo iptables -L prouvera que nos règles sont bien chargées.<br /> <br /> Comme je suis quelqu'un de gentil, voici quelques règles supplémentaires pour adapter votre script a vos besoins (je pense a rsync pour ceux qui ont lu un de mes précédent billet...) il y a juste a les commentaires si pas besoin et Attention, a placer impérativement avant les dernières ( celles que nous avons désignées par défaut..).<br /> <br /> <span class="text_code">Code BASH :</span><div class="code"><pre style="display:inline;"><pre class="bash" style="font-family:monospace;">&nbsp; <span style="color: #666666; font-style: italic;"># pour que le serveur FTP éventuel</span> <span style="color: #666666; font-style: italic;"># soit joignable de l'extérieur</span> &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">20</span> <span style="color: #660033;">-j</span> ACCEPT <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">21</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># pour que le serveur SSH éventuel</span> <span style="color: #666666; font-style: italic;"># soit joignable de l'extérieu</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour accepter les transferts rsync</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">873</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour que le serveur de mail éventuel</span> <span style="color: #666666; font-style: italic;"># soit joignable de l'extérieur</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">25</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour que le serveur de DNS éventuel</span> <span style="color: #666666; font-style: italic;"># soit joignable de l'extérieur</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-j</span> ACCEPT <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--dport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour que le serveur Web éventuel</span> <span style="color: #666666; font-style: italic;"># soit joignable de l'extérieur</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour autoriser Webmin</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$NET</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">10000</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour que le serveur CUPS éventuel</span> <span style="color: #666666; font-style: italic;"># soit joignable de l'extérieur</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">631</span> <span style="color: #660033;">-j</span> ACCEPT <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--dport</span> <span style="color: #000000;">631</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour que le serveur Samba éventuel</span> <span style="color: #666666; font-style: italic;"># soit joignable de l'extérieur</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">139</span> <span style="color: #660033;">-j</span> ACCEPT <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--dport</span> <span style="color: #000000;">139</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour que des clients puissent se connecter</span> <span style="color: #666666; font-style: italic;"># à l'ordinateur par XDMCP)</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--dport</span> <span style="color: #000000;">177</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour que l'odinateur puisse se connecte</span> <span style="color: #666666; font-style: italic;"># par XDMCP à une machine distante</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">6001</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pour que le serveur CVS éventuel</span> <span style="color: #666666; font-style: italic;"># soit joignable de l'extérieur via le mécanisme de &quot;pserver&quot;</span> <span style="color: #666666; font-style: italic;"># (si les utilisateurs accèdent au serveur CVS exclusivement via SSH,</span> <span style="color: #666666; font-style: italic;"># seule la ligne concernant le serveur SSH doit être décommentée</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">2401</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pouvoir reçevoir des flux VideoLAN</span> <span style="color: #666666; font-style: italic;"># (ce sont des flux UDP entrants sur le port 1234)</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--dport</span> <span style="color: #000000;">1234</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pouvoir reçevoir des annonces SAP</span> <span style="color: #666666; font-style: italic;"># (ce sont des annonces de session multicast)</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">-d</span> 224.2.127.254 <span style="color: #660033;">--dport</span> <span style="color: #000000;">9875</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp; <span style="color: #666666; font-style: italic;"># pouvoir utiliser GnomeMeeting</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">30000</span>:<span style="color: #000000;">33000</span> <span style="color: #660033;">-j</span> ACCEPT <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">1720</span> <span style="color: #660033;">-j</span> ACCEPT <span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-t</span> filter <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--dport</span> <span style="color: #000000;">5000</span>:<span style="color: #000000;">5006</span> <span style="color: #660033;">-j</span> ACCEPT &nbsp;</pre></pre></div><br /> <br /> Bon, la on en est qu'au début mais ce script si petit soit il constitue déjà une première barrière que nous allons faire évoluer, Il reste a voir et ajouter des modules supplémentaire comme ip_conntrak, ip_conntrack_ftp pour le suivit des connexions...<br /> je finirai plus tard car il reste de nombreuses choses a faire, nous n'avons la que la moitié de la base.<br /> <br /> Voici mes quelques sources : <br /> <br /> <a href="http://www.nbs-system.com/dossiers/howto-iptables.html">Un tuto hyper complet</a><br /> <br /> <a href="http://doc.ubuntu-fr.org/iptables">Encore un ici</a><br /> <br /> <a href="http://www.karlesnine.com/spip.php?article52">Et biensur les pages de man</a> Sun, 12 Oct 2008 14:52:01 +0200