Blog Entries tagged "command-line"

SSH Tunnels into Production Rails Database

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:

ssh -Ng -L <local-port>:<remote-host>:<remote-port> <user>@<remote-host>
ssh -Ng -L 3307:100.64.26.11:3307 adam@100.64.26.11

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.

development:
  adapter: mysql2
  database: myapp_production
  host: 127.0.0.1
  port: 3307
  username: root
  password

Read More...

Lookup IP Address & Location via the Command Line

With ifconfig.co, you can lookup your external IP Address and Location Information using a simple curl command. You can use it like so:

$ curl ifconfig.co/json
{
  "ip": "96.27.202.202",
  "ip_decimal": 1612409628,
  "country": "United States",
  "country_iso": "US",
  "city": "Columbus",
  "hostname": "d27-96-101-101.nap.wideopenwest.com"
}

$ curl ifconfig.co/city
Columbus

$ curl ifconfig.co/country
United States