Blog Entries tagged "command-line"

SSH Tunnels into Production Rails Database

<p>Today I needed to access a production database for my Rails app directly using a GUI application on my mac, so I figured out that this can be done by creating an SSH tunnel like so:</p> <div class="highlight"><pre class="highlight shell"><code>ssh <span class="nt">-Ng</span> <span class="nt">-L</span> &lt;local-port&gt;:&lt;remote-host&gt;:&lt;remote-port&gt; &lt;user&gt;@&lt;remote-host&gt; ssh <span class="nt">-Ng</span> <span class="nt">-L</span> 3307:100.64.26.11:3307 adam@100.64.26.11 </code></pre></div> <p>And then, in your Rails app, update the database.yml as if you were connecting to a local database, but specify the proper database name.</p> <div class="highlight"><pre class="highlight yaml"><code><span class="na">development</span><span class="pi">:</span> <span class="na">adapter</span><span class="pi">:</span> <span class="s">mysql2</span> <span class="na">database</span><span class="pi">:</span> <span class="s">myapp_production</span> <span class="na">host</span><span class="pi">:</span> <span class="s">127.0.0.1</span> <span class="na">port</span><span class="pi">:</span> <span class="m">3307</span> <span class="na">username</span><span class="pi">:</span> <span class="s">root</span> <span class="na">password</span></code></pre></div>

Read More...

Lookup IP Address & Location via the Command Line

<p>With <a href="https://ifconfig.co">ifconfig.co</a>, you can lookup your external IP Address and Location Information using a simple curl command. You can use it like so:</p> <div class="highlight"><pre class="highlight shell"><code><span class="nv">$ </span>curl ifconfig.co/json <span class="o">{</span> <span class="s2">"ip"</span>: <span class="s2">"96.27.202.202"</span>, <span class="s2">"ip_decimal"</span>: 1612409628, <span class="s2">"country"</span>: <span class="s2">"United States"</span>, <span class="s2">"country_iso"</span>: <span class="s2">"US"</span>, <span class="s2">"city"</span>: <span class="s2">"Columbus"</span>, <span class="s2">"hostname"</span>: <span class="s2">"d27-96-101-101.nap.wideopenwest.com"</span> <span class="o">}</span> <span class="nv">$ </span>curl ifconfig.co/city Columbus <span class="nv">$ </span>curl ifconfig.co/country United States </code></pre></div>