snipt

Ctrl+h for KB shortcuts
Notice: Snipt is moving away from free accounts on May 1st, 2014. Read more about the transition here.
#114552

Shell Session

Import sql file to MySQL database using SSH

mysql -p -u DB_USERNAME DB_NAME < PATH/TO/FILE.sql
https://snipt.net/embed/2889d808e26a0fbea9ed3b8e1bfeeecf/
https://snipt.net/raw/2889d808e26a0fbea9ed3b8e1bfeeecf/
2889d808e26a0fbea9ed3b8e1bfeeecf
shell-session
Shell Session
1
2014-04-23T11:51:47
True
False
Feb 17, 2014 at 05:03 PM
/api/public/snipt/114552/
import-sql-file-to-mysql-database-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 id="L-1"><a name="L-1"></a><span class="go">mysql -p -u DB_USERNAME DB_NAME &lt; PATH/TO/FILE.sql</span> </span></pre></div> </td></tr></table>
database, mysql, sql, ssh, terminal
#111141

Shell Session

Mount remote server drive with OSXFUSE and ssh

sshfs [-p PORT-NUMBER] USERNAME@MYDOMAIN.com:/remote/path /Local/Path/to/an/existing/folder
https://snipt.net/embed/178080a463bae7bdfcf47a9de1f1fd0b/
https://snipt.net/raw/178080a463bae7bdfcf47a9de1f1fd0b/
178080a463bae7bdfcf47a9de1f1fd0b
shell-session
Shell Session
1
2014-04-19T03:07:59
True
False
Feb 05, 2014 at 09:52 AM
/api/public/snipt/111141/
mount-remote-server-drive-with-osxfuse-and-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 id="L-1"><a name="L-1"></a><span class="go">sshfs [-p PORT-NUMBER] USERNAME@MYDOMAIN.com:/remote/path /Local/Path/to/an/existing/folder</span> </span></pre></div> </td></tr></table>
commandline, mac, server, ssh, terminal
#87287

Bash

SCP file from local to remote server over ssh using pem key

scp -i /path/to/key.pem /path/to/file.jpg <username>@<server ip address>:/path/to/place/file
https://snipt.net/embed/e1839c5e3d32b62b6ee527d714e4b2f8/
https://snipt.net/raw/e1839c5e3d32b62b6ee527d714e4b2f8/
e1839c5e3d32b62b6ee527d714e4b2f8
bash
Bash
1
2014-04-24T01:43:35
True
False
/api/public/snipt/87287/
scp-file-from-local-to-remote-server-over-ssh-using-pem-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 id="L-1"><a name="L-1"></a>scp -i /path/to/key.pem /path/to/file.jpg &lt;username&gt;@&lt;server ip address&gt;:/path/to/place/file </span></pre></div> </td></tr></table>
copy, file, local, remote, scp, server, ssh, to
#78646

Bash

Clear contents of file but dont delete it

cat /dev/null > file
https://snipt.net/embed/bb4c74f5bb5471cfee5e14aa071214d5/
https://snipt.net/raw/bb4c74f5bb5471cfee5e14aa071214d5/
bb4c74f5bb5471cfee5e14aa071214d5
bash
Bash
1
2014-04-23T20:27:36
True
False
Sep 03, 2013 at 05:12 AM
/api/public/snipt/78646/
clear-contents-of-file-but-dont-delete-it
<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 id="L-1"><a name="L-1"></a>cat /dev/null &gt; file </span></pre></div> </td></tr></table>
bash, clear, linux, ssh
#69685

Text only

Disable ssh host key checking in Linux

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user@server
https://snipt.net/embed/259724021f8d5001ce10aeed11e33b0f/
https://snipt.net/raw/259724021f8d5001ce10aeed11e33b0f/
259724021f8d5001ce10aeed11e33b0f
text
Text only
1
2014-04-23T13:51:16
True
False
Jul 26, 2013 at 05:12 AM
/api/public/snipt/69685/
disable-ssh-host-key-checking-in-linux
<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 id="L-1"><a name="L-1"></a>ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user@server </span></pre></div> </td></tr></table>
Linux, host-key-checking, ssh
#64882

Bash

SSH con certificato (pem) e utente

ssh -l USERNAME_HERE -i PTAH_TO_KEY.pem HOSTNAME
https://snipt.net/embed/cf64844c99b8fcc2bc30c0507241c5c2/
https://snipt.net/raw/cf64844c99b8fcc2bc30c0507241c5c2/
cf64844c99b8fcc2bc30c0507241c5c2
bash
Bash
1
2014-04-21T08:56:23
True
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 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
#58580

Text only

SSH Tunel to your Proxy Webbrowser

1
2
3
4
5
6
$ ssh -4 -N -D 1025 root@server.com

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/
https://snipt.net/raw/3e59a32f7f9530fc012e4d8c154525b5/
3e59a32f7f9530fc012e4d8c154525b5
text
Text only
7
2014-04-23T13:07:54
True
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 id="L-1"><a name="L-1"></a>$ ssh -4 -N -D 1025 root@server.com </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