Friday, April 29, 2011

Git cheat sheet

Yet another git help :)
This time cheat sheet (mostly for beginners):


Thursday, April 28, 2011

Dropbear sshd on Android device

Recently I needed to have SSH connection with Android development board but since no SSH daemon is included in the official Android release I had some troubles finding the right way to do it.

The following guide was tested on OMAP3 development board with Android Eclair but should be working on any (rooted/unlocked) phone with Android.

Instructions how to run dropbear sshd on Android device:

First you fetch the latest Dropbear sources:
git clone git://

Since the Android has different paths, no password support, etc. we must fix this in the original sources by applying the patch found here:
...the only problem is that it's for older version of Dropbear so we must try to apply it manually :(

After patch was applied build with:
./configure --host=arm-none-linux-gnueabi --disable-zlib
make CC=arm-none-linux-gnueabi-gcc

In case you're unable to apply the patch correctly or something went wrong with the build here is a archive with prebuilt binaries (dropbear, dropbearkey, dropbearconvert):

(Another guide how to build Dropbear for Android can be found @


To install dropbear on the desired gadget copy the binaries to some custom dir, e.g. /dropbear.

Setup the Server (Android):

Generate a RSA server key using dropbearkey:
dropbearkey -t rsa -f dropbear_rsa_host_key

Then create a dir /data/dropbear and copy dropbear_rsa_host_key there.

Test dropbear:
/dropbear/dropbear -r dropbear_rsa_host_key -F -E -v -s

This should show you the debuglog (the (-F) option means non-daemon mode).

Now we need to generate a key-pair for the client to connect with (Dropbear is run with the option -s (no-password) because there is no password support in Android):

//generates a private key
dropbearkey -t rsa -f /dropbear/id_rsa

//extract the public-key:
dropbearkey -f /dropbear/id_rsa -y > /dropbear/

We need to create /data/dropbear/.ssh and cat the public-key to authorized_keys:
mkdir /data/dropbear/.ssh
cat /dropbear/ > /data/dropbear/.ssh/authorized_keys

IMPORTATNT: Check the perms of /data/dropbear and make sure they are *only* readable/writable by root!

Setup the Client (Ubuntu):

As dropbear and openssh use different key formats we first need to convert id_rsa (private key) to openssh-format:
./dropbearconvert dropbear openssh /dropbear/id_rsa /dropbear/id_rsa_openssh

Now move id_rsa and id_rsa_openssh to your desktop (e.g. to your home dir).

Before establishing connection gadget's USB interface should be UP:
busybox ifconfig usb0 up
(yes, busybox must be installed on the Android device...)

Finally connect to the device:
ssh -i id_rsa_openssh <device-ip>

You can use -vv for both the client and the server to see debug info and fix whatever is wrong.

Setup the Client (Windows XP):

The only difference is that we use different SSH client. I used PuTTY.
- boot the board/phone
- connect PC with board with USB cable and wait for auto install
- set IP address (TCP/IP settings) in the automatically created USB Ethernet connection
- copy auth. keys generated with dropbear
- convert OpenSSH key to "PuTTY" key (ppk) using PuTTYGen
- open PuTTY and set remote IP/Port to connect to
- use SSH key generated with PuttyGen: Connection -> SSH -> Auth -> select key
- connect!

NOTE: The above is extended/edited version of the original guide @


Tuesday, April 19, 2011

Useful git commands

Some git commands that I found useful...

To remove all untracked files and dirs (aka "uber clean"):
$ git clean -f -d -X

For more useful/clear git log ouput:
$ git log --oneline --decorate

or  better use the following command:
$ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

You can add it as alias in ~/.gitconfig :

        lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

More @


Monday, April 18, 2011

Eee PC 901 paint job

At laaast! The 2-year warranty on my Eee PC 901 netbook has expired. Since I bought it its pearl white color was torture to my eyes (there were only white ones left at the store) but now I can finally pain it BLACK >:]

The disembowelment was kind of hard but here is the result:

Actually I was a bit surprised by of the assembly quality. Asus did a good job :)

Next I took all parts of the case, mask all necessary holes with duct tape (the mic, all the LED holes, etc.) and sand the parts a little. Then I removed any grease left and applied three layers of paint (with 2h for drying before applying the next  layer).

I left it for 24h to dry and here is it (I spent two hours assembling the damn thing):

Maybe not quite as I expected but it looks nice. :) Though I *should* have bought more expensive paint.
I left the battery white but maybe (someday) I'll paint it too. And maybe order some black keyboard & pad from ebay .... :)

Wednesday, April 13, 2011

Encode/Scale video with MEncoder

The only thing I don't like about my old Canon S3 IS camera is that it records video without compression. Meaning that 4min 640x480/30fps vid is about 512MB...
I spend some time playing with MEncoder ("...a free command line video decoding, encoding and filtering tool released under the GNU General Public License" and a really *great* tool) and found a way to encode (or scale) my videos from Linux command line:

Encode from Canon RAW (acceptable quality):
$ mencoder INPUT.mpeg -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1800:mbd=2:trell=yes:v4mv=yes -o output.avi
Scale video:
$ mencoder INPUT.mpeg -vf scale=320:240 -oac copy -ovc lavc -lavcopts vcodec=mpeg4 -o OUTPUT.mpeg


Create swap file in Linux

Some time ago when I was working with a BeableBoard-like dev board I had troubles creating Linux swap file. After reading some guides over the internet I'd like to share this simple how-to (Ubuntu):

1) Create "empty" file (~537 MB):
$ dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

2) Setup Linux swap area:
$ mkswap /swapfile1

3) Activate swap space immediately:
$ swapon /swapfile1

4) Add to fstab (optional):
/swapfile1 swap swap defaults 0 0

To test:
$ free -m

To deactivate:
$ swapoff /swapfile1

Hope that someone would find it useful :)

Tuesday, April 12, 2011

Different look for the Linux console

// lol...first "official" post

If you're bored of the default color your Linux console or want to change the look of it checkout the following example (Ubuntu):

Edit ~/.bash.rc with:

PS1="\n\[\e[32;40m\]| \[\e[31;40m\]\H \[\e[32;20m\]\d \[\e[32;1m\]\t \[\e[1;33m\]\w\[\e[0m\]\[\e[32;40m\]\n| \[\e[37;40m\]\u\[\e[1;37m\] \\$ \[\e[32;1m\]\[\e[0m\]"




Feel free to modify :)


Blog created.
Purpose yet unknown :)
Will post random stuff...