Sunday, March 10, 2013

SSH Tunnel to Remote MySQL (Port Forwarding)

ssh -f -L 13306:localhost:3306 -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

./ changepassword <username>

Run this in your project directory.

AirDroid - Manage your Android from your Computer Browser

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