blog.notmyidea.org/astuces-ssh.html

87 lines
No EOL
3.6 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<title>
Astuces <span class="caps">SSH</span> - Alexis Métaireau </title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="https://blog.notmyidea.org/theme/css/main.css?v2"
type="text/css" />
<link href="https://blog.notmyidea.org/feeds/all.atom.xml"
type="application/atom+xml"
rel="alternate"
title="Alexis Métaireau ATOM Feed" />
</head>
<body>
<div id="content">
<section id="links">
<ul>
<li>
<a class="main" href="/">Alexis Métaireau</a>
</li>
<li>
<a class=""
href="https://blog.notmyidea.org/journal/index.html">Journal</a>
</li>
<li>
<a class="selected"
href="https://blog.notmyidea.org/code/">Code, etc.</a>
</li>
<li>
<a class=""
href="https://blog.notmyidea.org/weeknotes/">Notes hebdo</a>
</li>
<li>
<a class=""
href="https://blog.notmyidea.org/lectures/">Lectures</a>
</li>
<li>
<a class=""
href="https://blog.notmyidea.org/projets.html">Projets</a>
</li>
</ul>
</section>
<header>
<h1 class="post-title">Astuces <span class="caps">SSH</span></h1>
<time datetime="2012-12-27T00:00:00+01:00">27 décembre 2012</time>
</header>
<article>
<h2 id="tunelling">Tunelling</h2>
<p>Parce que je m&#8217;en rapelle jamais (tête de&nbsp;linote):</p>
<div class="highlight"><pre><span></span><code>$<span class="w"> </span>ssh<span class="w"> </span>-f<span class="w"> </span>hote<span class="w"> </span>-L<span class="w"> </span>local:lolnet.org:destination<span class="w"> </span>-N
</code></pre></div>
<h2 id="sshconfig">.ssh/config</h2>
<p>(merci <a href="http://majerti.fr">gaston</a>&nbsp;!)</p>
<p>La directive suivante dans .ssh/config permet de sauter d&#8217;hôte en hôte
séparés par des &#8220;+&#8221;&nbsp;:</p>
<div class="highlight"><pre><span></span><code>Host <span class="gs">*+*</span>
ProxyCommand ssh $(echo %h | sed
&#39;s/+[^+]*$//;s/\([^+%%]*\)%%\([^+]*\)$/\2 -l \1/;s/:/ -p /&#39;)
PATH=.:\$PATH nc -w1 $(echo %h | sed &#39;s/^.*+//;/:/!s/$/ %p/;s/:/ /&#39;)
</code></pre></div>
<p>On peut donc spécifier des &#8220;sauts&#8221; ssh du&nbsp;style:</p>
<div class="highlight"><pre><span></span><code><span class="n">ssh</span><span class="w"> </span><span class="n">root</span><span class="mf">@91.25.25.25</span><span class="o">+</span><span class="mf">192.168.1.1</span>
</code></pre></div>
<p>Ensuite on peut essayer de&nbsp;rajouter:</p>
<div class="highlight"><pre><span></span><code>Host &lt;label_pour_mon_serveur_privé&gt;
user &lt;monuser(root)&gt;
IdentityFile &lt;chemin vers ma clé ssh pour le serveur publique&gt;
hostname ip_serveur_publique+ip_serveur_privé
</code></pre></div>
</article>
<footer>
<a id="feed" href="/feeds/all.atom.xml">
<img alt="RSS Logo" src="/theme/rss.svg" />
</a>
</footer>
</div>
</body>
</html>