blog.notmyidea.org/astuces-ssh.html

58 lines
No EOL
2.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>Astuces SSH - 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" 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>
<section id="links">
<li>
<a class="" href="https://blog.notmyidea.org/" id="site-title">Blog</a>
</li>
<li><a class="" href="https://blog.notmyidea.org/pages/projets.html">Projets</a></li>
</section>
<header>
<h1 class="post-title">Astuces SSH</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'en rapelle jamais (tête de linote):</p>
<div class="highlight"><pre><span></span><code>$ ssh -f hote -L local:lolnet.org:destination -N
</code></pre></div>
<h2 id="sshconfig">.ssh/config</h2>
<p>(merci <a href="http://majerti.fr">gaston</a> !)</p>
<p>La directive suivante dans .ssh/config permet de sauter d'hôte en hôte
séparés par des "+" :</p>
<div class="highlight"><pre><span></span><code><span class="err">Host *+*</span>
<span class="err"> ProxyCommand ssh $(echo %h | sed</span>
<span class="err">&#39;s/+[^+]*$//;s/\([^+%%]*\)%%\([^+]*\)$/\2 -l \1/;s/:/ -p /&#39;)</span>
<span class="err">PATH=.:\$PATH nc -w1 $(echo %h | sed &#39;s/^.*+//;/:/!s/$/ %p/;s/:/ /&#39;)</span>
</code></pre></div>
<p>On peut donc spécifier des "sauts" ssh du style:</p>
<div class="highlight"><pre><span></span><code><span class="n">ssh</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 rajouter:</p>
<div class="highlight"><pre><span></span><code><span class="err">Host &lt;label_pour_mon_serveur_privé&gt;</span>
<span class="err"> user &lt;monuser(root)&gt;</span>
<span class="err"> IdentityFile &lt;chemin vers ma clé ssh pour le serveur publique&gt;</span>
<span class="err"> hostname ip_serveur_publique+ip_serveur_privé</span>
</code></pre></div>
</article>
</body>
</html>