<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Amicalement Web - Astuces et Bons plans dans le développement web &#187; ssh</title>
	<atom:link href="http://www.amicalement-web.net/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.amicalement-web.net</link>
	<description>Astuces et bons plans d&#039;un web developpeur</description>
	<lastBuildDate>Wed, 04 Jan 2012 14:54:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Tips : Configuration de serveurs</title>
		<link>http://www.amicalement-web.net/tips-configuration-de-serveurs/2009/09/22/</link>
		<comments>http://www.amicalement-web.net/tips-configuration-de-serveurs/2009/09/22/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 08:34:45 +0000</pubDate>
		<dc:creator>Benoit</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tcpdump]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=750</guid>
		<description><![CDATA[Pour bien configurer un serveur, il existe plusieurs façons, chaque administrateur ayant la plupart du temps sa propre conf en fonction de ses habitudes et celles de ses users. Je vous propose ici quelques petits tips à mettre en place sur votre serveur pour voir un peu se qui s&#8217;y passe. Connexion SSH Il est [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/tips_config_serveur.png" alt="Tips : Configuration de serveurs" width="614" height="100" class="alignnone size-full wp-image-640" /></p>
<p>Pour bien configurer un serveur, il existe plusieurs façons, chaque administrateur ayant la plupart du temps sa propre conf en fonction de ses habitudes et celles de ses users.</p>
<p>Je vous propose ici quelques petits tips à mettre en place sur votre serveur pour voir un peu se qui s&#8217;y passe.</p>
<p><span id="more-750"></span></p>
<h3>Connexion SSH</h3>
<p>Il est toujours intéressant de connaître les <strong>connexions ssh</strong> des utilisateurs sur votre serveur, que ce soit pour des statistiques ou tout simplement surveiller les différentes connexions pour par exemple intervenir rapidement en cas d&#8217;intrusion.</p>
<p>Pour cela, il existe un moyen très simple avec l&#8217;utilisation de <strong>sshrc</strong>. Dans le man, il est dit :</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">/etc/ssh/sshrc
Commands in this file are executed by ssh when the user logs in,
just before the user's shell (or command) is started.
See the sshd(8) manual page for more information.</pre></div></div>

<p>Nous allons donc y introduire un petit bout de script qui enverra un mail automatiquement.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%d-%m-%Y %H:%M&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">IP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$SSH_CONNECTION</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">REVERSE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dig</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$IP</span> +short<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Message + envoi du mail</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;USER : <span style="color: #007800;">$USER</span>
IP : <span style="color: #007800;">$IP</span>
ReverseDNS : <span style="color: #007800;">$REVERSE</span>
Date : <span style="color: #007800;">$DATE</span>
&nbsp;
&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;[SSH] <span style="color: #007800;">$DATE</span> - Connexion de <span style="color: #007800;">$USER</span>&quot;</span> your_email<span style="color: #000000; font-weight: bold;">@</span>domaine.com</pre></div></div>

<p>A chaque connexion ssh d&#8217;un utilisateur, vous recevrez un mail contenant diverses informations. Je souligne au passage qu&#8217;un <strong>authentification ssh par clef</strong> est toujours plus sûre ;)</p>
<h3>Modifications de fichiers</h3>
<p>Il existe plusieurs applications (plus ou moins performantes) permettant de voir les fichiers modifiés sur votre serveur. Ici, un petit script tout bête qui va vous permette de voir <strong>les modifications effectuées depuis X jours</strong> sur votre serveur dans un ou plusieurs répertoires donnés.</p>
<p>Bien entendu c&#8217;est une surveillance basique, rien de comparable avec un contrôleur d&#8217;intégrité (tripwire par exemple), mais cela peut s&#8217;avérer très pratique, notamment pour retrouver rapidement une erreur faite dans un script après une modification, mais aussi pour vérifier qu&#8217;aucune modification externe n&#8217;est faite sur des fichiers sensibles.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%d-%m-%Y %H:%M&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">LAPS</span>=<span style="color: #000000;">1</span>
<span style="color: #007800;">INFOS</span>=<span style="color: #ff0000;">&quot;Liste des fichiers modifiés :<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-mtime</span> -<span style="color: #007800;">$LAPS</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-mtime</span> -<span style="color: #007800;">$LAPS</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$i</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #007800;">INFOS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$INFOS</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #007800;">$i</span>&quot;</span>
        <span style="color: #000000; font-weight: bold;">fi</span>;
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$INFOS</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;[MODIF] <span style="color: #007800;">$DATE</span> - Fichiers modifies&quot;</span> your_email<span style="color: #000000; font-weight: bold;">@</span>domaine.com</pre></div></div>

<p><em>N.B : Une vérification est faite pour n&#8217;avoir que les fichiers et non les répertoires + fichiers.</em></p>
<p>Dans l&#8217;instruction <strong>for i in &#8230; ; do</strong> vous pouvez mettre plusieurs répertoire en utilisant <strong>`find /rep/ -mtime -$LAPS`</strong>.</p>
<p>Une fois le script créé, il vous suffit de mettre en place un cron (ici à 23h59 tous les jours) qui le lancera automatiquement et vous avertira par mail des changements.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">59</span> <span style="color: #000000;">23</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>your<span style="color: #000000; font-weight: bold;">/</span>script</pre></div></div>

<h3>Consommation de bande passante</h3>
<p>Savoir qui consomme le plus de bande passante sur un serveur est souvent très intéressant, je vous propose donc ici un petit script qui va vous permettre de recevoir par mail les informations concernant les hôtes qui consomment le plus de bande passante, ici sur les <strong>10000 derniers paquets</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%d-%m-%Y %H:%M&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
tcpdump <span style="color: #660033;">-c</span> <span style="color: #000000;">10000</span> <span style="color: #660033;">-ni</span> eth0 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-lane</span> <span style="color: #ff0000;">'END{@keys=sort{$h{$a}  &lt;=&gt; $h{$b}} keys %h;for(reverse(@keys)){printf(&quot;%32s =&gt; %i\n&quot;, $_, $h{$_}) if($h{$_}&gt;100);}} $h{$F[1]}++;'</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;[BP] <span style="color: #007800;">$DATE</span> - Consommation bande passante&quot;</span> your_email<span style="color: #000000; font-weight: bold;">@</span>domaine.com</pre></div></div>

<p>A noter que pour faire plaisir à <a  href="http://blog.devorigin.fr/">Vincent</a>, j&#8217;ai utilisé du perl et non du python ^^</p>
<p>Une fois le script en place, un petit ajout dans le cron et c&#8217;est partit. Vous pouvez le faire tourner autant de fois que vous voulez, cela dépend surtout du traffic de votre serveur, ici 4 fois par jour soit toutes les 6 heures.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">* */6 * * * /path/to/your/script</pre></div></div>

<p>Voilà, si cela vous intéresse, il y aura surement d&#8217;autres tips à venir et surtout n&#8217;hésitez pas à demander si vous cherchez un petit truc particulier ou si vous avez des remarques.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/tips-configuration-de-serveurs/2009/09/22/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Déployer votre projet Symfony en production via rsync</title>
		<link>http://www.amicalement-web.net/deployer-votre-projet-symfony-en-production-via-rsync/2009/04/01/</link>
		<comments>http://www.amicalement-web.net/deployer-votre-projet-symfony-en-production-via-rsync/2009/04/01/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 10:08:53 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=181</guid>
		<description><![CDATA[Vous venez de boucler votre projet symfony en local et êtes impatients de le tester sur votre hébergement réel. Personnellement cette opération ne m&#8217;enchante jamais car les lettres FTP sonnent comme une évidence, or jamais un client FTP ne m&#8217;aura convaincu surtout quand un jour on a pu goûter au rsync. Ce petit logiciel libre [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/applications-other.png" alt="applications-other" title="applications-other" width="48" height="48" class="alignleft size-full wp-image-30" /> Vous venez de boucler votre projet symfony en local et êtes impatients de le tester sur votre hébergement réel. Personnellement cette opération ne m&#8217;enchante jamais car les lettres FTP sonnent comme une évidence, or jamais un client FTP ne m&#8217;aura convaincu surtout quand un jour on a pu goûter au <a  href="http://www.samba.org/rsync/" class="extern">rsync</a>.<br />
<span id="more-181"></span><br />
Ce petit logiciel libre permet en effet d&#8217;exporter très efficacement (rien à avoir avec le FTP) une arborescence vers une destination locale ou distante (utilise le ssh dans ce cas là) mais surtout ne copie que les éléments qui auront été modifiés (!). Évidemment, une fois votre première version en prod, vous aurez des modifications à faire, et il est toujours délicat de se rappeler les fichiers que l&#8217;on a modifiés. Cette problématique disparait avec rsync!</p>
<p>Et comme à son habitude, Symfony fait bien les choses car il intègre par défaut une option de déploiement basé sur cette technologie. Pour l&#8217;utiliser, il suffit de disposer de rsync sur les serveurs source et final. En général il suffit d&#8217;un:</p>

<div class="wp_syntax"><div class="code"><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> rsync</pre></div></div>

<p>Ensuite, éditez votre fichier <code>config/properties.ini</code> comme ceci, en remplaçant les paramètres selon vos informations:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>preprod<span style="">&#93;</span></span>
  <span style="color: #000099;">host</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">192.168.10.202                   #ip du serveur de destination</span>
  <span style="color: #000099;">port</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">22                               #port utilisé pour la connexion ssh, 22 est le port par défaut</span>
  <span style="color: #000099;">user</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">root                             #utilisateur qui se connectera au serveur de destination</span>
  <span style="color: #000099;">dir</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">/var/www/vhosts/monsite/httpdocs  #dossier qui recevera le projet symfony sur le serveur de destination</span>
  <span style="color: #000099;">type</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">rsync                            #le type de deploiement</span>
  <span style="color: #000099;">pass</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">                                 #indique qu'il y a un mot de passe <span style="">&#40;</span>il faudra le taper lors de la connexion<span style="">&#41;</span></span></pre></div></div>

<p>Un autre fichier <code>config/rsync_exclude.txt</code> permet d&#8217;exclure certains fichiers ou groupe de fichiers</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">.svn
/web/uploads/*
/cache/*
/log/*
/web/*_dev.php
.DS_Store
.cache
.project
.settings
/web/*Plugin</pre></div></div>

<p>Personnellement, une fois le projet déployé une fois, j&#8217;y ajoute également <code>config/ProjectConfiguration.class.php</code> contenant le lien vers votre installation de symfony, qui diffère parfois entre dev et prod.<br />
Concernant la règle <code>/web/*Plugin</code> qui regroupe les dossiers web des plugins, le problème vient des liens symboliques qui doivent être changés si le chemin de l&#8217;installation de symfony n&#8217;est pas identique en dev et en prod. Je les exclus donc du rsync et les republie après le rsync sur le serveur de prod via la ligne:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">php symfony plugin:publish-assets</pre></div></div>

<p>Voilà, c&#8217;est fini, il suffit maintenant de lancer la commande suivante à la racine de votre projet:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">php symfony project:deploy preprod</pre></div></div>

<p>preprod étant le nom que vous lui aurez donné le fichier ini. Cette commande ne fait qu&#8217;une simulation du transfert, pas d&#8217;inquiétude. Si tout se passe bien, vous pouvez lancer la commande finale:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">php symfony project:deploy preprod <span style="color: #660033;">--go</span></pre></div></div>

<p>Et vous assistez alors à la copie quasi instantanée de votre projet. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/deployer-votre-projet-symfony-en-production-via-rsync/2009/04/01/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
