Sunday, March 10, 2013

SSH Tunnel to Remote MySQL (Port Forwarding)

ssh -f -L 13306:localhost:3306 root@example.com -p 10022 -N

We block access to production MySQL servers over port 3306 for security reasons.  Here is an example connection string that proxies localhost port 13306 to port 3306 on the target system.

We use a few switched to make this easier to use:

Use -f to force SSH to go into background just before the SSH session starts.  This way you can get still be prompted for passwords but then run this in background.  We like this because then we don't have to have an open terminal all the time.

The -L switch indicates port:host:remoteport format. In this case, listen to socket 13306 on localhost and proxy to remote host port 3306.

The -p switch is special.  You might have to connect to SSH on a remote host on a port other than the standard 22.  It is starting to become common practice to change the SSH port on remote hosts to something else for security reasons.  In this example, the remote host only responds to SSH on port 10022.

Using -N tells SSH to NOT execute remote commands.  Useful when all you want this SSH session to do is port forwarding.

Thursday, March 7, 2013

Recover Lost Admin Password in Django


./manage.py changepassword <username>


Run this in your project directory.

AirDroid - Manage your Android from your Computer Browser

http://youtu.be/WfNnQxpw7Uw

I need to transfer some video files from my Ubuntu computer to my Nexus 7. I couldn't get MTP via USB to work right.

Luckily, I found this nice Android application (free - no ads) that gives you a simple virtual desktop of your Android in your browser. I was able to upload my videos over WiFi in just a few seconds.

You can get AirDroid in the Google Play Store

Tuesday, February 26, 2013

Quick YubiKey PAM Bash Installer

Quick YubiKey PAM Bash Installer

A quick and easy way to install YubiKey PAM for Ubuntu.  There is also a Bash installer for Debian in the same GitHub repo.

MySQL FOUND_ROWS() and OpenBD

We recently switched to OpenBD on a production website and it uses MySQL FOUND_ROWS().  There a couple of things to ensure it works properly on OpenBD.


You need to add this setting to the "Connection Settings" in the datasource


useDynamicCharsetInfo=false


The queries need to be in a cftransaction block otherwise they will use a different MySQL connection.   It would look something like:



<cftransaction>
<cfquery name="foo" datasource="foo">
    SELECT SQL_CALC_FOUND_ROWS * FROM foo 
    WHERE id > 2 LIMIT 2
  </cfquery>
  <cfquery name="bar" datasource="foo">
    SELECT FOUND_ROWS() AS numRows
  </cfquery>
</cftransaction>


Monday, February 18, 2013

Twitter Needs to Add Two-Factor Authentication

After the account of @BurgerKing hacked at Twitter, when is Twitter going to add two-factor authentication? Google and Facebook both have done it.

Friday, February 15, 2013

Excited for PyCon 2013 - Live Blogging It!

PyCon 2013 is the first conference since 2007 that I will be attending and not speaking at the conference itself.  So I actually feel like I can focus on being an attendee instead of a speaker.  So this is going to be a different experience for me and I'm already planning what I want to do at the conference.

I've decided I'm going to live blog the sessions that I attend at PyCon using Google Drive.  This means you'll be able to even watch me take my notes as the session goes on.  So I'll be blogging the live Google Doc links in a future blog post.  I'm so excited!  Watch this space...