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: adam@

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.

  adapter: mysql2
  database: myapp_production
  port: 3307
  username: root


Lookup IP Address & Location via the Command Line

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

$ curl
  "ip": "",
  "ip_decimal": 1612409628,
  "country": "United States",
  "country_iso": "US",
  "city": "Columbus",
  "hostname": ""

$ curl

$ curl
United States