<?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>Astuces d&#039;Absolacom &#187; ssh</title>
	<atom:link href="http://astuces.absolacom.com/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://astuces.absolacom.com</link>
	<description>La voie est libre mais pleine d&#039;achoppements</description>
	<lastBuildDate>Wed, 01 Feb 2012 17:59:43 +0000</lastBuildDate>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Voir l&#8217;occupation des dossiers avec NCDU</title>
		<link>http://astuces.absolacom.com/ubuntu/voir-loccupation-des-dossiers-avec-ncdu/</link>
		<comments>http://astuces.absolacom.com/ubuntu/voir-loccupation-des-dossiers-avec-ncdu/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 18:57:30 +0000</pubDate>
		<dc:creator>manuberro</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[logiciel]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[système]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://astuces.absolacom.com/?p=1047</guid>
		<description><![CDATA[Vous connaissez certainement Baobab, qui permet de naviguer rapidement dans le système de fichier pour trouver quel est le dossier ou le fichier qui prend tant de place1. Mais quand on se trouve sur une machine qui n&#8217;a pas d&#8217;interface graphique, ou par SSH ? Effectivement, on peut s&#8217;en sortir à grand coup de du, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://astuces.absolacom.com/wp-content/uploads/2011/04/complet.jpg"><img class="size-medium wp-image-1053 alignleft" title="complet" src="http://astuces.absolacom.com/wp-content/uploads/2011/04/complet-300x225.jpg" alt="" width="240" height="180" /></a>Vous connaissez certainement <a href="https://help.ubuntu.com/community/Baobab" target="_blank">Baobab</a>, qui permet de naviguer rapidement dans le système de fichier pour trouver quel est le dossier ou le fichier qui prend tant de place<sup><a href="http://astuces.absolacom.com/ubuntu/voir-loccupation-des-dossiers-avec-ncdu/#footnote_0_1047" id="identifier_0_1047" class="footnote-link footnote-identifier-link" title=" L&amp;#8217;&eacute;quivalent pour windows est WinDirStat ">1</a></sup>.</p>
<p>Mais quand on se trouve sur une machine qui n&#8217;a pas d&#8217;interface graphique, ou par SSH ?<br />
Effectivement, on peut s&#8217;en sortir à grand coup de <em>du</em>, <em>grep</em> et <em>find</em> .</p>
<p>Par exemple, et vous conviendrez que c&#8217;est<a href="http://fr.wikipedia.org/wiki/Ironie" target="_blank"> facile à mémoriser</a> :</p>
<blockquote><p><em>du -cks * | sort -rn | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e  &laquo;&nbsp;${size}${unit}\t${fname}&nbsp;&raquo;; break; fi; size=$((size/1024)); done; done</em>.</p></blockquote>
<p>Mais il n&#8217;est pas du tout pratique de se construire une représentation de l&#8217;arborescence pour agir efficacement et rapidement.</p>
<p>Confronté à un manque surprenant de place sur un NAS distant venant à peine d&#8217;être installé (500 Go / 1 mois), j&#8217;ai recherché un outil me permettant de trouver quel utilisateur squattait la place.<a href="http://astuces.absolacom.com/wp-content/uploads/2011/04/ncdu1.png"><img class="alignright size-thumbnail wp-image-1055" title="ncdu1" src="http://astuces.absolacom.com/wp-content/uploads/2011/04/ncdu1-150x150.png" alt="" width="150" height="150" /></a></p>
<p><a href="http://dev.yorhel.nl/ncdu" target="_blank">NCDU</a>, pour NCurses Disk Usage, permet d&#8217;analyser le système de fichier, en tout cas l&#8217;arborescence dans laquelle vous vous trouvez ou celle que vous lui indiquez, et de naviguer dedans. Et <a href="http://dev.yorhel.nl/ncdu/man" target="_blank">de supprimer</a> les fichiers/dossiers inutiles que vous rencontreriez.</p>
<p>Dans mon cas, supprimer le dossier de <a href="http://www.festivaldufilmdevacances.com/presentation_festival_2009.php?l=fr" target="_blank">films de vacances</a><sup><a href="http://astuces.absolacom.com/ubuntu/voir-loccupation-des-dossiers-avec-ncdu/#footnote_1_1047" id="identifier_1_1047" class="footnote-link footnote-identifier-link" title=" mouais&amp;#8230; ">2</a></sup> d&#8217;un utilisateur a permis de retrouver de quoi travailler confortablement pour les autres.</p>
<p>NCDU se trouve dans les dépôts officiels, et un simple <em>sudo apt-get install ncdu</em> vous permettra de profiter de ce formidable <em>cli tool</em>.</p>
<p><a href="http://astuces.absolacom.com/wp-content/uploads/2011/04/ncdu2.png"><img class="alignleft size-thumbnail wp-image-1057" title="ncdu2" src="http://astuces.absolacom.com/wp-content/uploads/2011/04/ncdu2-150x150.png" alt="" width="150" height="150" /></a></p>
Notes:<ol class="footnotes"><li id="footnote_0_1047" class="footnote"> L&#8217;équivalent pour windows est <a href="http://www.commentcamarche.net/download/telecharger-245-windirstat" target="_blank">WinDirStat</a> </li><li id="footnote_1_1047" class="footnote"> mouais&#8230; </li></ol>]]></content:encoded>
			<wfw:commentRss>http://astuces.absolacom.com/ubuntu/voir-loccupation-des-dossiers-avec-ncdu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Communiquer par un tunnel crypté SSH avec votre serveur comme relai (depuis Linux)</title>
		<link>http://astuces.absolacom.com/ubuntu/communiquer-par-un-tunnel-crypte-ssh-avec-votre-serveur-comme-relai-depuis-linux/</link>
		<comments>http://astuces.absolacom.com/ubuntu/communiquer-par-un-tunnel-crypte-ssh-avec-votre-serveur-comme-relai-depuis-linux/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 20:08:07 +0000</pubDate>
		<dc:creator>manuberro</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[logiciel]]></category>
		<category><![CDATA[messagerie]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[thunderbird]]></category>
		<category><![CDATA[tunnel]]></category>

		<guid isPermaLink="false">http://astuces.absolacom.com/?p=721</guid>
		<description><![CDATA[Lorsque vous êtes en déplacement, connecté en wifi à une borne gérée par on ne sait qui, il est délicat d&#8217;accéder à vos comptes bancaires ou votre messagerie en ayant l&#8217;esprit tranquille. En effet, rien n&#8217;empêche le propriétaire du point d&#8217;accès de surveiller tous les échanges sur cette borne, ou un pirate de sniffer les [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gramme.be/unite9/pmwiki/pmwiki.php?n=PrGC0607.Tunnelier"><img class="alignleft size-thumbnail wp-image-723" title="tunnelier" src="http://astuces.absolacom.com/wp-content/uploads/2010/06/tunnelier-150x150.jpg" alt="tunnelier" width="150" height="150" /></a>Lorsque vous êtes en déplacement, connecté en wifi à une borne gérée par on ne sait qui, il est délicat d&#8217;accéder à vos comptes bancaires ou votre messagerie en ayant l&#8217;esprit tranquille.</p>
<p>En effet, rien n&#8217;empêche le propriétaire du point d&#8217;accès de surveiller tous les échanges sur cette borne, ou un pirate de sniffer les communications.</p>
<p>Il est possible d&#8217;utiliser votre serveur qui tourne à la maison, (voire même un serveur kimsufi, dédibox, ou autre), comme relai pour vos communication, à la fois pour la navigation web et pour les mails. L&#8217;important étant que vous ayez confiance dans la machine qui va vous servir d&#8217;intermédiaire et du réseau sur lequel elle est connectée.</p>
<p>L&#8217;avantage, c&#8217;est que c&#8217;est rapide et simple à mettre en place, même au dernier moment.</p>
<h2>Précisions</h2>
<p>Un tunnel ssh ne permet de passer que des protocoles basés sur TCP, au contraire d&#8217;un VPN qui permet de transporter tout type de trame IP et non IP en plus d&#8217;apporter un routage complet. Ce n&#8217;est donc pas un VPN au sens réel du terme, mais cela va vous permettre d&#8217;utiliser la sécurité du SSH sur la partie du réseau qui n&#8217;est pas fiable.</p>
<h2>Creusons le tunnel</h2>
<p>Votre ordinateur relai devra, bien évidemment, avoir un serveur SSH accessible depuis l&#8217;extérieur. L&#8217;idéal étant de pouvoir s&#8217;y <a title="Accès SSH sans mot de passe" href="http://astuces.absolacom.com/non-classe/identification-ssh-sans-mot-de-passe/" target="_blank">connecter par clef plutôt que par mot de passe</a>, ce qui vous permettra de fermer l&#8217;authentification par clef et de limiter les attaques. Mais les deux fonctionnent.</p>
<p>Je vous laisser lire la documentation pour <a href="http://doc.ubuntu-fr.org/ssh" target="_blank">mettre en place un serveur ssh</a> si vous ne savez pas encore le faire.</p>
<p>Nous allons donc lancer une connexion vers notre serveur, et &laquo;&nbsp;binder&nbsp;&raquo; (lier) cette connexion à un port local afin que tout ce qui arrive sur le port local soit transféré sur la connexion SSH (<a title="Tranxen200" href="http://www.youtube.com/watch?v=2TcE8N-EOcg" target="_blank">et vice versa</a>). Dans un terminal, qu&#8217;il faudra laisser ouvert tout le temps de la session, entrez ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-D</span> <span style="color: #000000;">1234</span> utilisateur<span style="color: #000000; font-weight: bold;">@</span>serveur_relai</pre></div></div>

<p>Un <em> man ssh</em> vous donnera plus de détails sur le fait que l&#8217;option -D fait que SSH se comporte comme un serveur SOCKS et vous rappellera que seul root peut utiliser les ports privilégiés. Nous utilisons arbitrairement le port 1234, mais vous pouvez utiliser n&#8217;importe quel port local supérieur à 1024 (lancé par un utilisateur non root) à condition qu&#8217;<a title="Liste des ports et logiciels" href="http://fr.wikipedia.org/wiki/Liste_des_ports_logiciels" target="_blank">un service ne tourne pas déjà sur ce port</a>.</p>
<p>Si votre serveur ssh ne tournait pas sur le port par défaut, vous pourrez alors utiliser cette commande en précisant le port de votre serveur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-D</span> <span style="color: #000000;">1234</span>:port_ssh utilisateur<span style="color: #000000; font-weight: bold;">@</span>serveur_relai</pre></div></div>

<p>par exemple</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-D</span> <span style="color: #000000;">1234</span>:<span style="color: #000000;">443</span> utilisateur<span style="color: #000000; font-weight: bold;">@</span>serveur_relai</pre></div></div>

<p>ou</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-D</span> <span style="color: #000000;">1234</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">443</span> utilisateur<span style="color: #000000; font-weight: bold;">@</span>serveur_relai</pre></div></div>

<p>Si vous fermez le terminal dans lequel vous avez ouvert le tunnel, la communication serait fermée et vos logiciels ne pourraient plus sortir. Il faudra donc <strong>ne pas le fermer </strong>tout le temps de la session.</p>
<h2>Hey Ho, Hey Ho, on rentre &#8230; dans le tunnel</h2>
<p>Maintenant que nous avons créé notre tunnel, il faut indiquer aux logiciels de l&#8217;utiliser.</p>
<p><strong><span style="text-decoration: underline;">Par exemple, pour firefox:</span></strong></p>
<p><em>menu Édition &gt; Préférences &gt; Avancé &gt; Réseau &gt; Paramètres</em></p>
<p>Utilisez un proxy SOCKS qui est donc votre ordinateur (point de départ de la connexion SSH) sur le port indiqué (1234 dans ce cas) tel que ci dessous</p>
<p><a href="http://astuces.absolacom.com/wp-content/uploads/2010/06/FF_socks.png"><img class="aligncenter size-medium wp-image-722" title="FF_socks" src="http://astuces.absolacom.com/wp-content/uploads/2010/06/FF_socks-300x256.png" alt="Paramétrage pour Firefox" width="300" height="256" /></a></p>
<p>Pour vous convaincre que vous passez par votre serveur et non par la connexion wifi en cours, allez visiter un site comme <a title="Obtenir son adresse IP externe" href="http://www.monip.org/" target="_blank">http://www.monip.org/</a> qui vous montrera votre adresse IP externe. Si votre serveur a une IP fixe, vous reconnaitrez facilement votre IP. Sinon, visitez le site, un coup sans proxy, un coup avec, et vous verrez que l&#8217;ip n&#8217;est pas la même.</p>
<p><strong><span style="text-decoration: underline;">Par exemple, pour thunderbird:</span></strong></p>
<p>Les avantages de cette solution, pour envoyer du mail, sont:</p>
<ul>
<li>vous n&#8217;aurez pas à modifier le serveur SMTP d&#8217;envoi à chaque fois, même si des extentions existent pour compenser ce problème.</li>
<li>pas d&#8217;interception de vos mails par un éventuel proxy ou sniffer sur le réseau</li>
<li>l&#8217;adresse IP d&#8217;expédition est celle de votre serveur, pas celle de votre emplacement actuel (vie privée respectée)</li>
</ul>
<p>Rendez vous à <em>menu Édition &gt; Préférences &gt; Avancé &gt; Réseau et espace disque &gt; Paramètres</em> et paramétrez tel que sur l&#8217;image suivante:</p>
<p><a href="http://astuces.absolacom.com/wp-content/uploads/2010/06/TB_socks.png"><img class="aligncenter size-medium wp-image-726" title="TB_socks" src="http://astuces.absolacom.com/wp-content/uploads/2010/06/TB_socks-300x221.png" alt="Paramétrages de mozilla thunderbird" width="300" height="221" /></a></p>
<p>Lorsque vous enverrez un mail, il passera par le tunnel et sera donc réellement envoyé par votre serveur relai vers votre propre fournisseur d&#8217;accès, indépendamment du FAI depuis lequel vous êtes actuellement connecté.</p>
<p><strong><span style="text-decoration: underline;">Pour les autres logiciels:</span></strong></p>
<p>Le principe du paramétrage est identique aux exemples ci dessus. Cherchez dans leur configuration comment utiliser un proxy socks.</p>
<h2>Ça peut aussi ne pas fonctionner!</h2>
<p>En effet, si un proxy est paramétré sur votre réseau (pas chez vous, là où vous êtes connecté) et qu&#8217;il ne laisse pas passer le ssh, vous êtes bloqué. Mais il existe parfois des solutions:</p>
<ul>
<li>Si le blocage du ssh est dû aux ports qui sont autorisés, il vous faudra mettre votre serveur ssh (chez vous) en écoute sur un de ceux ci. Il y a de fortes chances pour que le http et le https soient autorisés (sinon le proxy ne servirait à rien, autant débrancher le câble&#8230;).</li>
<li>Si le blocage est dû à l&#8217;analyse des flux par le proxy et que le ssh est refusé, il faudra passer par un tunnel http dans lequel vous ferez passer un tunnel ssh (ou ce que vous voudrez). Vous pouvez utiliser l&#8217;excellent <a title="Utilisation de httptunnel" href="http://doc.ubuntu-fr.org/httptunnel" target="_blank">http-tunnel</a> qui vous sortira de l&#8217;impasse.</li>
<li>Si le proxy utilise un filtrage applicatif en plus du reste&#8230; c&#8217;est que l&#8217;admin est un acharné et que vous n&#8217;arriverez pas à sortir par cette voie.</li>
</ul>
<p>Notez qu&#8217;il est possible de <a href="http://inaps.org/articles/linux-logiciel-libre/putty_ssh_tunnel" target="_blank">faire la même chose</a> avec <a title="Site de putty" href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" target="_blank">putty</a> et <a title="Winquoi?" href="http://www.google.fr/#hl=fr&amp;safe=off&amp;q=comment+installer+linux&amp;aq=f&amp;aqi=g10&amp;aql=&amp;oq=&amp;gs_rfai=&amp;fp=757540d489aa8d30" target="_blank">Windows</a> mais je vous laisser faire ça seuls, n&#8217;ayant plus de licence depuis longtemps, et encore moins l&#8217;envie de me salir les mains avec ça.</p>
<h4>A lire aussi:</h4>
<ul>
<li><a href="http://proxytunnel.sourceforge.net/paper.php" target="_blank">http://proxytunnel.sourceforge.net/paper.php</a></li>
<li><a href="http://forum.ubuntu-fr.org/viewtopic.php?id=213500" target="_blank">http://forum.ubuntu-fr.org/viewtopic.php?id=213500</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://astuces.absolacom.com/ubuntu/communiquer-par-un-tunnel-crypte-ssh-avec-votre-serveur-comme-relai-depuis-linux/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Filtrer les connexions ssh</title>
		<link>http://astuces.absolacom.com/ubuntu/filtrer-les-connexions-ssh/</link>
		<comments>http://astuces.absolacom.com/ubuntu/filtrer-les-connexions-ssh/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 19:14:24 +0000</pubDate>
		<dc:creator>manuberro</dc:creator>
				<category><![CDATA[logiciel]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://astuces.absolacom.com/?p=184</guid>
		<description><![CDATA[Portier SSH Si vous possédez un serveur avec SSH opérationnel, vous ne serez pas long à avoir des messages tels que ceux ci dans le fichier /var/log/auth.log: ... Mar 11 12:48:21 serv sshd&#91;12956&#93;: Failed password for invalid user root from 64.71.148.162 port 47270 ssh2 Mar 11 15:45:04 serv sshd&#91;6954&#93;: Did not receive identification string from [...]]]></description>
			<content:encoded><![CDATA[<h2>Portier SSH</h2>
<p>Si vous possédez un serveur avec SSH opérationnel, vous ne serez pas long à avoir des messages tels que ceux ci dans le fichier <em>/var/log/auth.log</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
Mar <span style="color: #000000;">11</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">48</span>:<span style="color: #000000;">21</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">12956</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Failed password <span style="color: #000000; font-weight: bold;">for</span> invalid user root from 64.71.148.162 port <span style="color: #000000;">47270</span> ssh2
Mar <span style="color: #000000;">11</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">45</span>:04 serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">6954</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Did not receive identification string from 210.21.30.72
Mar <span style="color: #000000;">11</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">46</span>:<span style="color: #000000;">48</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7041</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Did not receive identification string from 81.93.188.5
Mar <span style="color: #000000;">11</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">50</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7106</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: User root from 210.21.30.72 not allowed because none of user s <span style="color: #c20cb9; font-weight: bold;">groups</span> are listed <span style="color: #000000; font-weight: bold;">in</span> AllowGroups
Mar <span style="color: #000000;">11</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">50</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7106</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: pam_unix<span style="color: #7a0874; font-weight: bold;">&#40;</span>sshd:auth<span style="color: #7a0874; font-weight: bold;">&#41;</span>: authentication failure; <span style="color: #007800;">logname</span>= <span style="color: #007800;">uid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">euid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">tty</span>=<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">ruser</span>= <span style="color: #007800;">rhost</span>=210.21.30.72  <span style="color: #007800;">user</span>=root
Mar <span style="color: #000000;">11</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">47</span>:<span style="color: #000000;">52</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7106</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Failed password <span style="color: #000000; font-weight: bold;">for</span> invalid user root from 210.21.30.72 port <span style="color: #000000;">54346</span> ssh2
Mar <span style="color: #000000;">11</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">49</span>:<span style="color: #000000;">33</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7241</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: User root from 81.93.188.5 not allowed because none of user s <span style="color: #c20cb9; font-weight: bold;">groups</span> are listed <span style="color: #000000; font-weight: bold;">in</span> AllowGroups
Mar <span style="color: #000000;">11</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">49</span>:<span style="color: #000000;">33</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7241</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: pam_unix<span style="color: #7a0874; font-weight: bold;">&#40;</span>sshd:auth<span style="color: #7a0874; font-weight: bold;">&#41;</span>: authentication failure; <span style="color: #007800;">logname</span>= <span style="color: #007800;">uid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">euid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">tty</span>=<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">ruser</span>= <span style="color: #007800;">rhost</span>=81.93.188.5  <span style="color: #007800;">user</span>=root
Mar <span style="color: #000000;">11</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">49</span>:<span style="color: #000000;">35</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7241</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Failed password <span style="color: #000000; font-weight: bold;">for</span> invalid user root from 81.93.188.5 port <span style="color: #000000;">44663</span> ssh2
Mar <span style="color: #000000;">12</span> 00:<span style="color: #000000;">51</span>:<span style="color: #000000;">18</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">22229</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: User root from host.ongamemarketing.com not allowed because none of user s <span style="color: #c20cb9; font-weight: bold;">groups</span> are listed <span style="color: #000000; font-weight: bold;">in</span> AllowGroups
Mar <span style="color: #000000;">12</span> 00:<span style="color: #000000;">51</span>:<span style="color: #000000;">18</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">22229</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: pam_unix<span style="color: #7a0874; font-weight: bold;">&#40;</span>sshd:auth<span style="color: #7a0874; font-weight: bold;">&#41;</span>: authentication failure; <span style="color: #007800;">logname</span>= <span style="color: #007800;">uid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">euid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">tty</span>=<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">ruser</span>= <span style="color: #007800;">rhost</span>=host.ongamemarketing.com  <span style="color: #007800;">user</span>=root
Mar <span style="color: #000000;">12</span> 00:<span style="color: #000000;">51</span>:<span style="color: #000000;">20</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">22229</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Failed password <span style="color: #000000; font-weight: bold;">for</span> invalid user root from 174.133.12.130 port <span style="color: #000000;">48089</span> ssh2
Mar <span style="color: #000000;">12</span> 00:<span style="color: #000000;">51</span>:<span style="color: #000000;">22</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">22236</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: User root from host.ongamemarketing.com not allowed because none of user s <span style="color: #c20cb9; font-weight: bold;">groups</span> are listed <span style="color: #000000; font-weight: bold;">in</span> AllowGroups
Mar <span style="color: #000000;">12</span> 00:<span style="color: #000000;">51</span>:<span style="color: #000000;">22</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">22236</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: pam_unix<span style="color: #7a0874; font-weight: bold;">&#40;</span>sshd:auth<span style="color: #7a0874; font-weight: bold;">&#41;</span>: authentication failure; <span style="color: #007800;">logname</span>= <span style="color: #007800;">uid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">euid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">tty</span>=<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">ruser</span>= <span style="color: #007800;">rhost</span>=host.ongamemarketing.com  <span style="color: #007800;">user</span>=root
Mar <span style="color: #000000;">12</span> 00:<span style="color: #000000;">51</span>:<span style="color: #000000;">24</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">22236</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Failed password <span style="color: #000000; font-weight: bold;">for</span> invalid user root from 174.133.12.130 port <span style="color: #000000;">48521</span> ssh2
Mar <span style="color: #000000;">12</span> 01:<span style="color: #000000;">47</span>:<span style="color: #000000;">10</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">30827</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Did not receive identification string from 114.200.199.144
Mar <span style="color: #000000;">12</span> 01:<span style="color: #000000;">53</span>:<span style="color: #000000;">17</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">31227</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Invalid user staff from 114.200.199.144
Mar <span style="color: #000000;">12</span> 01:<span style="color: #000000;">53</span>:<span style="color: #000000;">17</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">31227</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: pam_unix<span style="color: #7a0874; font-weight: bold;">&#40;</span>sshd:auth<span style="color: #7a0874; font-weight: bold;">&#41;</span>: check pass; user unknown
Mar <span style="color: #000000;">12</span> 01:<span style="color: #000000;">53</span>:<span style="color: #000000;">17</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">31227</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: pam_unix<span style="color: #7a0874; font-weight: bold;">&#40;</span>sshd:auth<span style="color: #7a0874; font-weight: bold;">&#41;</span>: authentication failure; <span style="color: #007800;">logname</span>= <span style="color: #007800;">uid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">euid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">tty</span>=<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">ruser</span>= <span style="color: #007800;">rhost</span>=114.200.199.144
Mar <span style="color: #000000;">12</span> 01:<span style="color: #000000;">53</span>:<span style="color: #000000;">19</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">31227</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Failed password <span style="color: #000000; font-weight: bold;">for</span> invalid user staff from 114.200.199.144 port <span style="color: #000000;">35343</span> ssh2
Mar <span style="color: #000000;">12</span> 01:<span style="color: #000000;">53</span>:<span style="color: #000000;">27</span> serv sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">31234</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Invalid user sales from 114.200.199.144
...</pre></div></div>

<p>Vous avez besoin de pouvoir vous connecter en ssh depuis le réseau local, depuis l&#8217;extérieur, mais vous voulez limiter les risques. Il existe plusieurs solutions, qui peuvent être cumulées:</p>
<h2>Sécuriser par la configuration de SSH</h2>
<h3>N&#8217;autoriser QUE certains utilisateurs à accéder au service</h3>
<p>Si vous avez peu d&#8217;utilisateurs nécessitant un accès ssh, vous pouvez les déclarer ainsi en ajoutant cette ligne dans le fichier de configuration <em>/etc/ssh/sshd_config </em>(et en redémarrant le service après chaque modification<em>)<br />
</em></p>

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

<p>Après relance du service ssh, les utilisateurs <em>titi</em> et <em>toto</em> pourront se connecter en ssh, les autres utilisateurs se verront refuser leur mot de passe.</p>
<p>Vous pouvez aussi créer un groupe (par exemple: <em>sshusers</em>) et autoriser tous les utilisateurs de ce groupe à se connecter en ssh. Ceux n&#8217;appartenant pas à ce groupe se verront refuser leur mot de passe.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">addgroup sshusers
adduser toto sshusers
adduser titi sshusers</pre></div></div>

<p>Puis ajoutez la ligne suivante dans /etc/ssh/sshd_config:</p>

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

<h3>IN and OUT</h3>
<p>Oui, mais voilà un nouveau problème:</p>
<ol>
<li> Le serveur fait passerelle avec internet, et possède une carte sur le réseau interne, et une carte vers le réseau internet.</li>
<li> Tous mes utilisateurs internes doivent pouvoir accéder par ssh (ce qui est le cas avec la configuration par défaut), mais ne doivent pas pouvoir accéder depuis l&#8217;extérieur (parce qu&#8217;ils n&#8217;en ont pas besoin, ou parce que les mots de passe des utilisateurs sont trop simples)</li>
<li> Si je laisse la configuration ainsi, le serveur sera piraté très rapidement.</li>
</ol>
<p>Il est possible d&#8217;ajouter une directive à la liste des autorisations, permettant de faire ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">AllowUsers <span style="color: #000000; font-weight: bold;">*@</span>192.168.0.<span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p>Ainsi, tous les utilisateurs du réseau local (et possédant un compte sur le serveur) pourront accéder par ssh, mais ne pourront pas le faire s&#8217;ils ne proviennent pas du réseau local (par internet).<br />
Si je veux pouvoir ensuite me connecter depuis l&#8217;internet pour faire de la télémaintenance, il me suffit d&#8217;ajouter mon compte et de transformer la ligne en ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">AllowUsers manu <span style="color: #000000; font-weight: bold;">*@</span>192.168.0.<span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p>(1)</p>
<p>Il est possible aussi de cumuler les directives Users et Groups pour obtenir des possibilités supplémentaires. Exemple:</p>
<ol>
<li>Seuls certains de mes utilisateurs locaux doivent pouvoir se connecter au serveur, depuis le net ou en local.</li>
<li>Je veux pouvoir m&#8217;y connecter de partout (local et internet)</li>
</ol>
<p>La configuration est la suivante:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">AllowGroups sshusers
AllowUsers manu</pre></div></div>

<p>Ainsi, seuls les utilisateurs appartenant au groupe sshusers pourront se connecter au serveur, en plus de l&#8217;utilisateur manu qui pourra se connecter depuis n&#8217;importe où.</p>
<p>Si je possède un adresse IP fixe, et que je suis assez bête pour crée un compte manu avec le mot de passe manu, je peux tout de même limiter l&#8217;accès par mon adresse IP (80.80.80.80)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">AllowUsers <span style="color: #000000; font-weight: bold;">@</span>80.80.80.80</pre></div></div>

<h3>Je suis désolé, ça va pas être possible&#8230;</h3>
<p>Vous pouvez même ajouter des directives inverses, pour interdire les connexions:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DenyUsers invite
DenyGroups stagiaires</pre></div></div>

<h3>Autres configurations conseillées de ssh</h3>
<p>Vous pouvez modifier d&#8217;autres éléments du fichier de configuration, qui permettront de sécuriser un peu plus votre serveur ssh:</p>
<ul>
<li> <strong>Changer le port d&#8217;écoute par défaut: </strong>vous pouvez changer ce port par autre chose que 22. Sachez cependant que la protection apportée par ce changement est TRÈS FAIBLE. Un scan de vos port repérera le port que vous avez choisi, et des logiciels de scans sont capable de déterminer le service qui tourne derrière ce port. Cela vous permettra seulement d&#8217;échapper à certains robots qui ne tentent des connexions que sur le port 22.</li>
<li><strong><a title="SSH sans mot de passe" href="http://www.lea-linux.org/documentations/index.php/Trucs:Connection_SSH_sans_mot_de_passe" target="_blank">N&#8217;autoriser une identification que par clef</a>:</strong> il vous faudra générer des clefs d&#8217;identification (avec seahorse pour gnome ou ssk-keygen) pour tous vos utilisateurs et empêcher l&#8217;autentification par mot de passe dans la configuration de SSH. Cette protection est très efficace, par contre, il faut que les clefs soient sécurisées (pas sur une clef usb qui peut se perdre ou se faire voler, pas sur un partage accessible, pas échangées par courriel, &#8230;). L&#8217;autre inconvénient, c&#8217;est que vos clefs doivent voyager avec vous et être installées sur les ordinateurs que vous utilisez; d&#8217;où une incompatibilité avec le point précédent, si vous n&#8217;avez pas une politique stricte de stockage des clefs.</li>
<li><strong>Ne JAMAIS autoriser la connexion de l&#8217;utilisateur root: </strong>(PermitRootLogin no).  Il y a toujours un utilisateur root sur tous les Linux (<span style="text-decoration: underline;">même sur Ubuntu</span>) et vous facilitez le travail d&#8217;un éventuel pirate, puisqu&#8217;il n&#8217;a qu&#8217;un mot de passe à trouver. Autrement, il doit d&#8217;abord trouver un login valide, puis son mot de passe, puis celui du root. Si vos mots de passe et vos logins sont adaptés, cela lui prendra des années avant d&#8217;y arriver par ce moyen.</li>
</ul>
<h2>Ajouter des logiciels de sécurisation</h2>
<h3>fail2ban</h3>
<p><a title="Site de fail2ban" href="http://www.fail2ban.org/wiki/index.php/Main_Page" target="_blank">fail2ban</a> est un logiciel qui va surveiller les tentatives de connexion échouées dans le fichier<em> /var/log/auth.log</em> , et bloquer, en modifiant les règles iptables à la volée, un nombre trop élevé de connexions échouées. Ce logiciel permet aussi, de la même manière, de protéger votre serveur apache, postfix, vsftpd, proftpd, wuftpd, sasl, dns, &#8230;<br />
Une fois installé, il vous suffit d&#8217;éditer le fichier <em>/etc/fail2ban/jail.conf</em> pour configurer son comportement. Exemple pour ssh:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
<span style="color: #7a0874; font-weight: bold;">&#91;</span>DEFAULT<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #666666; font-style: italic;"># &quot;ignoreip&quot; can be an IP address, a CIDR mask or a DNS host</span>
ignoreip = <span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">class</span>=<span style="color: #ff0000;">&quot;linkification-ext&quot;</span> <span style="color: #007800;">title</span>=<span style="color: #ff0000;">&quot;Linkification: http://10.0.0.0/24&quot;</span> <span style="color: #007800;">href</span>=<span style="color: #ff0000;">&quot;http://10.0.0.0/24&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>10.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span><span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span>
bantime  = <span style="color: #000000;">600</span>
maxretry = <span style="color: #000000;">3</span>
...
<span style="color: #7a0874; font-weight: bold;">&#91;</span>SECTION_NAME<span style="color: #7a0874; font-weight: bold;">&#93;</span>
enabled = <span style="color: #c20cb9; font-weight: bold;">true</span> <span style="color: #666666; font-style: italic;"># vérifier que cette valeur est à True, sinon le logiciel n'est pas activé!</span>
...
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">ssh</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
enabled = <span style="color: #c20cb9; font-weight: bold;">true</span>
port	= <span style="color: #c20cb9; font-weight: bold;">ssh</span>
filter	= sshd
logpath  = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>auth.log
maxretry = <span style="color: #000000;">6</span></pre></div></div>

<p>Dans cette configuration:</p>
<ul>
<li>Tout ce qui vient du réseau local (<a class="linkification-ext" title="Linkification: http://10.0.0.0/24" href="http://10.0.0.0/24">10.0.0.0/24</a>) est ignoré. Donc je pourrais me tromper autant de fois que voulu, je ne me ferais pas bannir.</li>
<li>En dehors de mon réseau local, par ssh, j&#8217;ai droit à 6 tentatives (par session) de connexions échouées. Ensuite, je me ferais bannir. Si je m&#8217;identifie, la fois suivante, j&#8217;ai encore droit à 6 tentative (ça repart à zéro avec l&#8217;identification réussie)</li>
<li>Si je suis banni, toutes mes tentatives de connexions pendant les 600 prochaines secondes (10 minutes) seront refusées, sans possibilité d&#8217;identification.</li>
</ul>
<p>La configuration de fail2ban vous offre plein d&#8217;autres possibilité, comme de recevoir des mails en cas de tentatives échouées, d&#8217;utilisateurs inconnus, etc. Consultez la documentation pour exploiter cet outils très pratique.</p>
<h3>denyhosts</h3>
<p><a href="http://www.howtoforge.com/preventing_ssh_dictionary_attacks_with_denyhosts" target="_blank">denyhosts</a> permet de faire la même chose, un peu différemment. Il maintient une base d&#8217;IP bannies dans <em>/etc/hosts.deny</em> et les compare avec les tentatives de connexions.</p>
<p>Il a quelques avantages sur fail2ban, même si je le trouve plus lent (consommateur) à l&#8217;usage:</p>
<ol>
<li>Il permet de bloquer les tentatives d&#8217;accès ssh sur l&#8217;utilisateur root dès la première tentative.</li>
<li>Il permet de paramétrer comme on le veut les champs from et subject des mails envoyés</li>
<li>Il permet d&#8217;envoyer les rapports vers le syslog, qui peut être distant (et ineffaçable)</li>
</ol>
<p>Simple à configurer, le fichier<em> /etc/denyhosts.conf</em> est largement commenté</p>
<h2>Sur le même sujet:</h2>
<ul>
<li><a href="http://www.fail2ban.org/wiki/index.php/FAQ_french" target="_blank">http://www.fail2ban.org/wiki/index.php/FAQ_french</a></li>
<li><a href="http://doc.ubuntu-fr.org/denyhosts" target="_blank">http://doc.ubuntu-fr.org/denyhosts</a></li>
<li><a href="http://www.alsacreations.com/tuto/lire/622-Securite-firewall-iptables.html" target="_blank">http://www.alsacreations.com/tuto/lire/622-Securite-firewall-iptables.html</a></li>
<li><a href="http://senseya.free.fr/index.php?tag/fail2ban" target="_blank">http://senseya.free.fr/index.php?tag/fail2ban</a></li>
</ul>
<p>(1) Ne pensez pas que je suis assez bête pour utiliser un login simple tel que &laquo;&nbsp;manu&nbsp;&raquo; sur mes serveurs&#8230; C&#8217;est juste pour l&#8217;exemple.</p>
]]></content:encoded>
			<wfw:commentRss>http://astuces.absolacom.com/ubuntu/filtrer-les-connexions-ssh/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>rkhunter et unhide</title>
		<link>http://astuces.absolacom.com/serveur/rkhunter-et-unhide/</link>
		<comments>http://astuces.absolacom.com/serveur/rkhunter-et-unhide/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 14:49:06 +0000</pubDate>
		<dc:creator>manuberro</dc:creator>
				<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[système]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://astuces.absolacom.com/?p=189</guid>
		<description><![CDATA[Unhide est un utilitaire permettant de lister les processus actifs cachés. C&#8217;est un outil qui vous permet de trouver d&#8217;éventuels rootkits installés sur votre système. S&#8217;il n&#8217;est pas installé par défaut sur votre distribution, installez le de manière classique. Si vous utilisez rkhunter pour scanner votre machine, sans opération particulière vous aurez deux problèmes: rkhunter [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.security-projects.com/?Unhide" target="_blank">Unhide</a> est un utilitaire permettant de lister les processus actifs cachés. C&#8217;est un outil qui vous permet de trouver d&#8217;éventuels <a href="http://fr.wikipedia.org/wiki/Rootkit" target="_blank">rootkits</a> installés sur votre système.</p>
<p>S&#8217;il n&#8217;est pas installé par défaut sur votre distribution, installez le de manière classique.</p>
<p>Si vous utilisez <a href="http://fr.wikipedia.org/wiki/Rkhunter" target="_blank">rkhunter</a> pour scanner votre machine, sans opération particulière vous aurez deux problèmes:</p>
<ol>
<li>rkhunter n&#8217;utilisera pas par défaut unhide, et vous perdrez donc le bénéfice d&#8217;un seul scan.</li>
<li>rkhunter va détecter un warning sur unhide et unhide-linux26, ce qui vous enverra un mail à chaque détection.</li>
</ol>
<p>La solution est simple: il suffit d&#8217;indiquer à rkhunter que unhide est fiable, en l&#8217;ajoutant à sa base de donnée. Ensuite, rkhunter utilisera unhide automatiquement.</p>
<p><span style="color: #ff0000;"><strong>ATTENTION: n&#8217;utilisez la commande suivante QUE SI VOUS ÊTES SÛR de votre système ! En effet, cette commande va réinitialiser la base de données des programmes considérés comme sûrs par rkhunter. Si vous avez un rootkit ou des programmes cachés, ils ne seront plus détectés!</strong></span></p>
<p><span style="color: #ff0000;"><strong>Il est conseillé de lancer un <em>rkhunter -c</em> et de vérifier le rapport avant de lancer la commande suivante.</strong></span></p>
<p>Maintenant que vous êtes prévenus, voici la commande magique (en root ou avec sudo):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rkhunter <span style="color: #660033;">--propupd</span></pre></div></div>

<p>C&#8217;est tout. La prochaine fois que rkhunter sera lancé, manuellement ou par la programmation, unhide sera détecté et utilisé.</p>
]]></content:encoded>
			<wfw:commentRss>http://astuces.absolacom.com/serveur/rkhunter-et-unhide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Identification SSH sans mot de passe</title>
		<link>http://astuces.absolacom.com/non-classe/identification-ssh-sans-mot-de-passe/</link>
		<comments>http://astuces.absolacom.com/non-classe/identification-ssh-sans-mot-de-passe/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 13:28:10 +0000</pubDate>
		<dc:creator>manuberro</dc:creator>
				<category><![CDATA[developpement]]></category>
		<category><![CDATA[logiciel]]></category>
		<category><![CDATA[Non classé]]></category>
		<category><![CDATA[planet-libre]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[système]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://astuces.absolacom.com/?p=80</guid>
		<description><![CDATA[Pour utiliser SSH (et dérivés tels que sftp) sans mot de passe, il faut ajouter votre clef sur le serveur. Nous aurons donc un ordinateur (manu-desktop) qui pourra se connecter à un serveur (server) par ssh sans avoir besoin de spécifier de mot de passe. Notez qu&#8217;il existe des outils graphiques pour réaliser ces opérations [...]]]></description>
			<content:encoded><![CDATA[<p>Pour utiliser SSH (et dérivés tels que sftp) sans mot de passe, il faut ajouter votre clef sur le serveur. Nous aurons donc un ordinateur (<em>manu-desktop</em>) qui pourra se connecter à un serveur (<em>server</em>) par ssh sans avoir besoin de spécifier de mot de passe.</p>
<p>Notez qu&#8217;il existe des outils graphiques pour réaliser ces opérations (par exemple seahorse sous Gnome), mais je n&#8217;en parlerais pas.</p>
<h2>Sur l&#8217;ordinateur client (<em>manu-desktop</em>)</h2>
<p>La première chose à faire, si vous n&#8217;avez pas de clef pour votre machine, est d&#8217;en générer une</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">manu<span style="color: #000000; font-weight: bold;">@</span>manu-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span>
Generating public<span style="color: #000000; font-weight: bold;">/</span>private rsa key pair.
Enter <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #c20cb9; font-weight: bold;">which</span> to save the key <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>manu<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa<span style="color: #7a0874; font-weight: bold;">&#41;</span>:
Created directory <span style="color: #ff0000;">'/home/manu/.ssh'</span>.
Enter passphrase <span style="color: #7a0874; font-weight: bold;">&#40;</span>empty <span style="color: #000000; font-weight: bold;">for</span> no passphrase<span style="color: #7a0874; font-weight: bold;">&#41;</span>:
Enter same passphrase again:
Your identification has been saved <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>manu<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.
Your public key has been saved <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>manu<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub.
The key fingerprint is:
<span style="color: #7a0874; font-weight: bold;">cd</span>:9e:bb:0a:1e:<span style="color: #000000;">22</span>:<span style="color: #000000;">29</span>:fa:e3:<span style="color: #c20cb9; font-weight: bold;">dc</span>:<span style="color: #000000;">12</span>:<span style="color: #000000;">72</span>:8a:<span style="color: #000000;">15</span>:<span style="color: #000000;">13</span>:<span style="color: #000000;">58</span> manu<span style="color: #000000; font-weight: bold;">@</span>manu-desktop
manu<span style="color: #000000; font-weight: bold;">@</span>manu-desktop:~$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh
total <span style="color: #000000;">8</span>,0K
<span style="color: #000000;">3367418</span> <span style="color: #660033;">-rw-------</span> <span style="color: #000000;">1</span> manu manu <span style="color: #000000;">1</span>,7K <span style="color: #000000;">2009</span>-01-<span style="color: #000000;">15</span> <span style="color: #000000;">13</span>:<span style="color: #000000;">26</span> id_rsa
<span style="color: #000000;">3367419</span> <span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> manu manu  <span style="color: #000000;">399</span> <span style="color: #000000;">2009</span>-01-<span style="color: #000000;">15</span> <span style="color: #000000;">13</span>:<span style="color: #000000;">26</span> id_rsa.pub
manu<span style="color: #000000; font-weight: bold;">@</span>manu-desktop:~$</pre></div></div>

<p>Ne mettez pas de passphrase et laisser les options par défaut pour la création de la clef. Il est aussi possible de spécifier les options via la ligne de commande:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-qt</span> rsa <span style="color: #660033;">-b</span> <span style="color: #000000;">1024</span> <span style="color: #660033;">-C</span> manu <span style="color: #660033;">-f</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>manu<span style="color: #000000; font-weight: bold;">@</span>manu-desktop.rsa <span style="color: #660033;">-N</span> <span style="color: #ff0000;">&quot;&quot;</span></pre></div></div>

<p>La commande précédente crée une clef rsa (-t) avec le commentaire (-C) manu d&#8217;une longueur de 1024 bits (-b) dans le fichier ~/.ssh/manu@manu-desktop.rsa (-f) avec une passphrase (-N) vide.</p>
<h2>Sur le serveur (<em>server</em>)</h2>
<p>Le compte utilisateur de connexion doit exister. Il n&#8217;est pas obligé que ce soit le même identifiant que sur le client.  Par exemple, sur le serveur, mon compte est nommé <strong>zephir</strong>.</p>
<pre class="brush: python; title: ; notranslate">
[root@server]:# adduser zephir
Ajout de l'utilisateur « zephir »...
Ajout du nouveau groupe « zephir » (1002)...
Ajout du nouvel utilisateur « zephir » (1002) avec le groupe « zephir »...
Création du répertoire personnel « /home/zephir »...
Copie des fichiers depuis « /etc/skel »...
Entrez le nouveau mot de passe UNIX :
Retapez le nouveau mot de passe UNIX :
passwd : le mot de passe a été mis à jour avec succès
Modification des informations relatives à l'utilisateur zephir
Entrez la nouvelle valeur ou « Entrée » pour conserver la valeur proposée
Nom complet []:
N° de bureau []:
Téléphone professionnel []:
Téléphone personnel []:
Autre []:
Ces informations sont-elles correctes ? [o/N] o
[root@server]:#
</pre>
<h2>Sur l&#8217;ordinateur client (<em>manu-desktop</em>), fin des opérations</h2>
<p>Il ne reste plus au client qu&#8217;à envoyer sa clef d&#8217;identification au serveur simplement par la commande suivante:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ssh-copy-id <span style="color: #660033;">-i</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub zephir<span style="color: #000000; font-weight: bold;">@</span>server</pre></div></div>

<p>Acceptez l&#8217;identification du serveur, le mot de passe est demandé (puisque vous n&#8217;avez pas encore envoyé la clef) et la clef est copiée dans le fichier /home/zephir/.ssh/authorized_keys.<br />
Tentez la commande suivante (Ctrl+D pour sortir)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> zephir<span style="color: #000000; font-weight: bold;">@</span>server</pre></div></div>

<p>Vous ne devriez plus avoir de demande de mot de passe.</p>
<h2>Sur le serveur, fin des opérations</h2>
<p>Il est possible de sécuriser le serveur afin de n&#8217;accepter que les authentifications avec clef et sans demande de mot de passe (pour ssh. L&#8217;accès en local demandera toujours un mot de passe).<br />
Ainsi, les tentatives d&#8217;attaque par force brute sont vouées à l&#8217;échec. MAIS, soyez conscient que vous ne pourrez plus vous connecter depuis une autre machine que celle pour laquelle vous avez envoyé la clef, pas plus que vous ne pourrez envoyer d&#8217;autres clefs.<br />
Paramétrez le fichier /etc/ssh/sshd_config tel que ci dessous:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Authentication:</span>
LoginGraceTime <span style="color: #000000;">120</span>
PermitRootLogin <span style="color: #c20cb9; font-weight: bold;">yes</span>
StrictModes <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
RSAAuthentication <span style="color: #c20cb9; font-weight: bold;">yes</span>
PubkeyAuthentication <span style="color: #c20cb9; font-weight: bold;">yes</span>
AuthorizedKeysFile      <span style="color: #000000; font-weight: bold;">%</span>h<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys
&nbsp;
<span style="color: #666666; font-style: italic;"># Change to no to disable tunnelled clear text passwords</span>
PasswordAuthentication no</pre></div></div>

<p>Relancez ensuite le serveur ssh pour prendre en compte les modifications.</p>
<h3>Note sur la sécurité</h3>
<p>L&#8217;accès au serveur est possible sans authentification par l&#8217;utilisateur manu depuis l&#8217;ordinateur client <em>(manu-desktop</em>). Si cet ordinateur est un portable et qu&#8217;il se fait voler, celui qui arrivera à se connecter avec l&#8217;identité de manu arrivera sans demande de mot de passe à se connecter au serveur !<br />
Réfléchissez bien à l&#8217;utilisation de ce mode de fonctionnement avant de le mettre en place.<br />
En cas de vol, il suffira de supprimer le fichier /home/zephir/.ssh/authorized_keys pour que la clef volée avec le portable ne soit plus opérationnelle.<br />
Vous pouvez, de même, recréer et changer vos clefs d&#8217;identification lorsque vous le voulez en réutilisant les commandes données en début d&#8217;article.</p>
<p>Liens:</p>
<p><a title="gnugpg" href="http://doc.ubuntu-fr.org/gnupg" target="_blank">http://doc.ubuntu-fr.org/gnupg</a><br />
<a title="Documentation ssh sur Ubuntu" href="http://doc.ubuntu-fr.org/ssh" target="_blank">http://doc.ubuntu-fr.org/ssh</a></p>
]]></content:encoded>
			<wfw:commentRss>http://astuces.absolacom.com/non-classe/identification-ssh-sans-mot-de-passe/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

