snipt

Ctrl+h for KB shortcuts

Bash

How to prevent SSH sessions to die for timeout

1
2
3
Add this in /etc/ssh_config

ServerAliveInterval 60
https://snipt.net/embed/e4eb3f3ad970026754d8f3e83e926dc1/
/raw/e4eb3f3ad970026754d8f3e83e926dc1/
e4eb3f3ad970026754d8f3e83e926dc1
bash
Bash
3
2019-07-26T20:00:29
True
False
True
Jun 14, 2013 at 10:06 AM
/api/public/snipt/38062/
come-non-far-morire-le-sessioni-ssh-aggiungendo-questa-riga-in-etcssh_config
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>Add this in /etc/ssh_config </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>ServerAliveInterval 60 </span></pre></div> </td></tr></table>
ssh

Bash

drush change password script for drupal 7 users

drush user-password someuser --password="[email protected]@$s"
https://snipt.net/embed/b57caad6f1d96c22b9c7065da64a9d64/
/raw/b57caad6f1d96c22b9c7065da64a9d64/
b57caad6f1d96c22b9c7065da64a9d64
bash
Bash
1
2019-08-16T03:48:23
True
False
False
/api/public/snipt/36890/
drush-change-password-script-for-drupal-7-users
<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>drush user-password someuser --password<span class="o">=</span><span class="s2">&quot;[email protected]@</span><span class="nv">$s</span><span class="s2">&quot;</span> </span></pre></div> </td></tr></table>
drupal, drupal7, drush, ssh

Bash

Get JAVA_HOME from alternatives

JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:bin/javac::")
https://snipt.net/embed/ba28f6bb37015f10aee79e793f2a8488/
/raw/ba28f6bb37015f10aee79e793f2a8488/
ba28f6bb37015f10aee79e793f2a8488
bash
Bash
1
2019-08-07T22:05:26
True
False
False
/api/public/snipt/36797/
get-java_home-from-alternatives
<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><span class="nv">JAVA_HOME</span><span class="o">=</span><span class="k">$(</span>readlink -f /usr/bin/javac <span class="p">|</span> sed <span class="s2">&quot;s:bin/javac::&quot;</span><span class="k">)</span> </span></pre></div> </td></tr></table>
bash, linux, ssh

Text only

SSH Tunnel

1
2
3
4
5
ssh -C2qTnN -L local_port:localhost:remote_port [email protected]_host

ssh -f [email protected] -L 2000:personal-server.com:25 -N

ssh -D [bind_address:]port
https://snipt.net/embed/c6f9f0107c73b49ee588790ee2445d2c/
/raw/c6f9f0107c73b49ee588790ee2445d2c/
c6f9f0107c73b49ee588790ee2445d2c
text
Text only
5
2019-08-15T16:19:37
True
False
False
May 21, 2013 at 07:56 AM
/api/public/snipt/35741/
ssh-tunnel-3
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>ssh -C2qTnN -L local_port:localhost:remote_port [email protected]_host </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>ssh -f [email protected] -L 2000:personal-server.com:25 -N </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>ssh -D [bind_address:]port </span></pre></div> </td></tr></table>
ssh, tunnel

Bash

unzip and import db

gunzip < backup.sql.gz | mysql -u root -p dbname
https://snipt.net/embed/058a54b6f5c6be5b02e1afcede9dbdec/
/raw/058a54b6f5c6be5b02e1afcede9dbdec/
058a54b6f5c6be5b02e1afcede9dbdec
bash
Bash
1
2019-08-20T08:15:43
True
False
False
/api/public/snipt/34170/
unzip-and-import-db
<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>gunzip &lt; backup.sql.gz <span class="p">|</span> mysql -u root -p dbname </span></pre></div> </td></tr></table>
mysql, ssh

Bash

Add SSH Public Key to a server.

ssh-copy-id [email protected]
https://snipt.net/embed/6e9566c195f35e05e9c309a8a292d46c/
/raw/6e9566c195f35e05e9c309a8a292d46c/
6e9566c195f35e05e9c309a8a292d46c
bash
Bash
1
2019-08-16T08:10:33
True
False
False
/api/public/snipt/28643/
add-ssh-public-key-to-a-server
<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-copy-id [email protected] </span></pre></div> </td></tr></table>
"public key", bash, copy, security, ssh

Bash

generate ssh key

ssh-keygen -b 4096 -t dsa -f filename
https://snipt.net/embed/779c999a7ab2e994f60c97d030df3edb/
/raw/779c999a7ab2e994f60c97d030df3edb/
779c999a7ab2e994f60c97d030df3edb
bash
Bash
2
2019-08-19T12:36:34
True
False
False
/api/public/snipt/27980/
generate-ssh-key
<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-keygen -b <span class="m">4096</span> -t dsa -f filename </span></pre></div> </td></tr></table>
key, ssh