snipt

Ctrl+h for KB shortcuts

Ruby

ssh port forwarding

#This forwards all localhost:1234 connections to google.com:80 through gimli
ssh -L 1234:google.com:80 gimli.cs.berkeley.edu
https://snipt.net/embed/554defb67545e7a2885fa8560c668925/
/raw/554defb67545e7a2885fa8560c668925/
554defb67545e7a2885fa8560c668925
rb
Ruby
2
2019-06-25T12:43:57
True
False
False
/api/public/snipt/8832/
ssh-port-forwarding
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">#This forwards all localhost:1234 connections to google.com:80 through gimli</span> </span><span id="L-2"><a name="L-2"></a><span class="n">ssh</span> <span class="o">-</span><span class="n">L</span> <span class="mi">1234</span><span class="ss">:google</span><span class="o">.</span><span class="n">com</span><span class="p">:</span><span class="mi">80</span> <span class="n">gimli</span><span class="o">.</span><span class="n">cs</span><span class="o">.</span><span class="n">berkeley</span><span class="o">.</span><span class="n">edu</span> </span></pre></div> </td></tr></table>
forwarding, mysql, server, shell, ssh

Bash

Generate SSH keypairs

ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
https://snipt.net/embed/23674ab97c9298374947d9484e10ccee/
/raw/23674ab97c9298374947d9484e10ccee/
23674ab97c9298374947d9484e10ccee
bash
Bash
3
2019-06-25T12:44:08
True
False
False
/api/public/snipt/6975/
generate-ssh-keypairs
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>ssh-keygen -t rsa </span><span id="L-2"><a name="L-2"></a>cat ~/.ssh/id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys </span></pre></div> </td></tr></table>
login, security, shell, ssh

Bash

SSH Streaming tar

ssh $SERVER tar -czf - $FILEDIR > $LOCALFILE.tgz
https://snipt.net/embed/7586d5131571a483fd351a6ad3d17f4a/
/raw/7586d5131571a483fd351a6ad3d17f4a/
7586d5131571a483fd351a6ad3d17f4a
bash
Bash
1
2019-06-26T17:51:16
True
False
False
/api/public/snipt/6901/
ssh-streaming-tar
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>ssh <span class="nv">$SERVER</span> tar -czf - <span class="nv">$FILEDIR</span> &gt; <span class="nv">$LOCALFILE</span>.tgz </span></pre></div> </td></tr></table>
archive, shell, ssh, tar

Bash

Tar to a pipe, doesnt use diskspace

tar -cf - ./filename | (cd other-directory; tar -xf -)
https://snipt.net/embed/f400281d56a70cd05b1e5f06a2b9b346/
/raw/f400281d56a70cd05b1e5f06a2b9b346/
f400281d56a70cd05b1e5f06a2b9b346
bash
Bash
1
2019-06-25T22:50:34
True
False
False
/api/public/snipt/6899/
tar-to-a-pipe-doesnt-use-diskspace
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>tar -cf - ./filename <span class="p">|</span> <span class="o">(</span><span class="nb">cd</span> other-directory<span class="p">;</span> tar -xf -<span class="o">)</span> </span></pre></div> </td></tr></table>
compress, shell, ssh, tar