snipt

Ctrl+h for KB shortcuts

Bash

SSH con certificato (pem) e utente

ssh -l USERNAME_HERE -i PTAH_TO_KEY.pem HOSTNAME
https://snipt.net/embed/cf64844c99b8fcc2bc30c0507241c5c2/
/raw/cf64844c99b8fcc2bc30c0507241c5c2/
cf64844c99b8fcc2bc30c0507241c5c2
bash
Bash
1
2019-06-11T20:48:55
True
False
False
Jun 19, 2013 at 07:33 AM
/api/public/snipt/64882/
ssh-con-certificato-pem-e-utente
<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 -l USERNAME_HERE -i PTAH_TO_KEY.pem HOSTNAME </span></pre></div> </td></tr></table>
conn, ssh, utils

Text only

SSH Tunel to your Proxy Webbrowser

1
2
3
4
5
6
$ ssh -4 -N -D 1025 [email protected]

1025 is a proxy port (localhost:1025)
it work with socks v5!

// http://www.sebastian.korotkiewicz.eu/2013/03/30/ssh-tunel-to-your-proxy-webbrowser/
https://snipt.net/embed/3e59a32f7f9530fc012e4d8c154525b5/
/raw/3e59a32f7f9530fc012e4d8c154525b5/
3e59a32f7f9530fc012e4d8c154525b5
text
Text only
7
2019-06-15T20:20:28
True
False
False
Mar 30, 2013 at 07:45 PM
/api/public/snipt/58580/
ssh-tunel-to-your-proxy-webbrowser
<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> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ ssh -4 -N -D 1025 [email protected] </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>1025 is a proxy port (localhost:1025) </span><span id="L-4"><a name="L-4"></a>it work with socks v5! </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a>// http://www.sebastian.korotkiewicz.eu/2013/03/30/ssh-tunel-to-your-proxy-webbrowser/ </span></pre></div> </td></tr></table>
bash, linux, ssh, tunel

Bash

Restart of SSH Connections

pstree -cpal | egrep [s]shd | perl -lne '($i)=(/(\d+)/); `kill -1 $i`'
https://snipt.net/embed/8f8b6190734e8065fec2cd0b33808997/
/raw/8f8b6190734e8065fec2cd0b33808997/
8f8b6190734e8065fec2cd0b33808997
bash
Bash
1
2019-06-19T15:06:36
True
False
False
Dec 20, 2012 at 05:53 AM
/api/public/snipt/52131/
restart-of-ssh-connections
<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>pstree -cpal <span class="p">|</span> egrep <span class="o">[</span>s<span class="o">]</span>shd <span class="p">|</span> perl -lne <span class="s1">&#39;($i)=(/(\d+)/); `kill -1 $i`&#39;</span> </span></pre></div> </td></tr></table>
restart, ssh, unix

Bash

Preventing Git cert error

env GIT_SSL_NO_VERIFY=true git clone https://bitbucket.org/user/repo.git
https://snipt.net/embed/517bc21864aa314d2a7bda5ef5f4f51f/
/raw/517bc21864aa314d2a7bda5ef5f4f51f/
517bc21864aa314d2a7bda5ef5f4f51f
bash
Bash
2
2019-06-17T08:16:34
True
False
False
Nov 23, 2012 at 08:58 AM
/api/public/snipt/50666/
preventing-git-cert-error
<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>env <span class="nv">GIT_SSL_NO_VERIFY</span><span class="o">=</span><span class="nb">true</span> git clone https://bitbucket.org/user/repo.git </span></pre></div> </td></tr></table>
cert, git, https, prevent, ssh

Bash

Compact tar.bz2 and on destination

1
2
3
#This is useful when you don't have much space on server, and need backup or copy
#So, you can backup direct to destination.
tar -cf - /home/dir_backup |bzip2 -9vv | ssh [email protected] "cat > /backups/dir_backup.tar.bz2"
https://snipt.net/embed/ff3556c4d1185c97e7eacbd696ca6a35/
/raw/ff3556c4d1185c97e7eacbd696ca6a35/
ff3556c4d1185c97e7eacbd696ca6a35
bash
Bash
4
2019-06-18T13:43:49
True
False
False
Sep 29, 2012 at 03:39 PM
/api/public/snipt/47820/
compact-tarbz2-and-on-destination
<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><span class="c1">#This is useful when you don&#39;t have much space on server, and need backup or copy</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">#So, you can backup direct to destination.</span> </span><span id="L-3"><a name="L-3"></a>tar -cf - /home/dir_backup <span class="p">|</span>bzip2 -9vv <span class="p">|</span> ssh [email protected] <span class="s2">&quot;cat &gt; /backups/dir_backup.tar.bz2&quot;</span> </span></pre></div> </td></tr></table>
backup, bz2, bzip2, ssh, tar, tar.bz2

Text only

Mysql dump using SSH

mysqldump --opt -u [dbuser] -p [dbname]> [filename].sql
https://snipt.net/embed/93535cce40c45c2f80c726e5c078f6a7/
/raw/93535cce40c45c2f80c726e5c078f6a7/
93535cce40c45c2f80c726e5c078f6a7
text
Text only
1
2019-06-19T11:17:43
True
False
False
Jan 15, 2014 at 08:56 PM
/api/public/snipt/43134/
mysql-dump-using-ssh
<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>mysqldump --opt -u [dbuser] -p [dbname]&gt; [filename].sql </span></pre></div> </td></tr></table>
cmd, command-line, console, linux, mysql, mysqldump, server, ssh

Bash

SCP (secure copy) file from local machine to remote server over SSH

scp /local-file/folder/name.zip [email protected]:path-to-post-too/subfolder/
https://snipt.net/embed/caf9a9fd1a7a1e3fa7ff1616bd01af69/
/raw/caf9a9fd1a7a1e3fa7ff1616bd01af69/
caf9a9fd1a7a1e3fa7ff1616bd01af69
bash
Bash
1
2019-06-15T06:40:01
True
False
False
/api/public/snipt/42328/
scp-secure-copy-file-from-local-machine-to-remote-server-over-ssh
<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>scp /local-file/folder/name.zip [email protected]:path-to-post-too/subfolder/ </span></pre></div> </td></tr></table>
bash, scp, ssh

Text only

Zip a folder and subfolders using SSH

zip -r -q [NAME].zip *
https://snipt.net/embed/dd0ca3e1c292ed2dd73a7f376ba510cc/
/raw/dd0ca3e1c292ed2dd73a7f376ba510cc/
dd0ca3e1c292ed2dd73a7f376ba510cc
text
Text only
1
2019-06-17T17:34:22
True
False
False
/api/public/snipt/40113/
zip-a-folder-and-subfolders-using-ssh
<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>zip -r -q [NAME].zip * </span></pre></div> </td></tr></table>
cmd, command-line, linux, server, ssh, zip

Bash

rsync move files to server

rsync -arzv -e ssh folder [email protected]:/destination-folder
https://snipt.net/embed/5257113eb28985496906572ddb047234/
/raw/5257113eb28985496906572ddb047234/
5257113eb28985496906572ddb047234
bash
Bash
1
2019-06-17T14:31:22
True
False
False
/api/public/snipt/38711/
rsync-move-files-to-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>rsync -arzv -e ssh folder [email protected]:/destination-folder </span></pre></div> </td></tr></table>
rsync, ssh