Saturday, March 07, 2015

Burning RASPBIAN Linux image onto micro sd card

Recently I got Raspberry PI 2 and I got around to burning RASPBIAN image onto micro SD card.

Here is a step by step guide what I did:

Please note that the use of the dd tool can overwrite any partition of your machine. If you specify the wrong device in the instructions below you could delete your primary Linux partition. Please be careful.
  • Run df -h to see what devices are currently mounted.
  • Insert the micro sd card into your computer
  • Run df -h again. The new device that has appeared is your SD card. The left column gives the device name of your SD card.On my machine it was listed as /dev/sdb1 . The last part (i.e. 1) is the partition number.
  • Run umount /dev/sdb1 
  • In the terminal, write the image to the card with the command:
sudo dd bs=4M if=2015-02-16-raspbian-wheezy.img of=/dev/sdb
  • Run sync to ensure the write cache is flushed and that it is safe to unmount your SD card.
  • Remove the SD card from the card reader.

I did this all in Virtualbox VM, therefore did not have hard disk space in the VM to dd-ing from the micro SD card back to another image on my hard disk.If I had the hard disk space in the VM I would have done the following to check what had be writtten to the SD card:
sudo dd bs=4M if=/dev/sdb of=from-sd-card.img
sudo truncate --reference 2015-02-16-raspbian-wheezy.img from-sd-card.img
diff -s from-sd-card.img 2015-02-16-raspbian-wheezy.img


diff should report that the files are identical.

Sunday, March 02, 2014

Installing Node.js on Ubuntu 12.04

Download the source of Node.js for Linux. Make sure you have the Ubuntu package 'build-essential' already installed before building Node.js.

You can check if Ubuntu package 'build-essential' is already installed by issuing the following command on the terminal:

suleman@devbox:~$apt-cache policy build-essential 
build-essential:
  Installed: 11.5ubuntu2.1
  Candidate: 11.5ubuntu2.1
  Version table:
 *** 11.5ubuntu2.1 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise-updates/main amd64

The above Installed line indicates, which version of  'build-essential' is installed, if it was not installed then you would have seen something like the following:
build-essential:
  Installed: Installed: (none)
  Candidate: 11.5ubuntu2.1
  Version table:
 *** 11.5ubuntu2.1 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise-updates/main amd64

If you don't have package 'build-essential' installed then please install it:
suleman@devbox:~$sudo apt-get install build-essential

Issue the following commands in the terminal to build Node.js for local use as opposed to system wide use:
suleman@devbox:~$tar xzf node-v0.10.26.tar.gz
suleman@devbox:~$cd node-v0.10.26
suleman@devbox:~/node-v0.10.26$./configure
suleman@devbox:~/node-v0.10.26$make
suleman@devbox:~/node-v0.10.26$mkdir ~/local
suleman@devbox:~/node-v0.10.26$./configure --prefix=~/local
suleman@devbox:~/node-v0.10.26$make && make install

Then  I would add the following in your ~/.bashrc:
export PATH=~/local/bin:$PATH

Either open new terminal or source ~/.bashrc in current terminal and check you have node installed successful:
suleman@devbox:~$node -v
v0.10.26

I installed Node.js for tutorial I was doing on AngularJS, once I have finished this tutorial I am hoping to have look in anger at Node.js for server side programming.

The book Node: Up and Running looks good for Node.js server side programming.

Friday, August 19, 2011

Ubuntu 11.4 using Gnome Keyring as a SSH agent

It has been a long time since I tried public key authentication for SSH (2005 was the last time I did this).

Well since then 'Gnome Keyring SSH Agent' has been added by Linux distributions, as I found out to my surprise when I typed the following into Linux terminal:

ssh roy@example.com

I got the following pop-up, which I did not expect:



I expected the following message because I created non standard named key (i.e. roy_ssh_key) and did not specify the identity file when running ssh command:

Permission denied (publickey).

'Gnome Keyring SSH Agent' found both the public (roy_ssh_key.pub) and private (roy_ssh_key) keys in the directory ~/.ssh and was trying to load the private key into 'Gnome Keyring SSH Agent' and was asking for the private key password.

If you enter the private key password in the 'Unlock private key' dialogue then the private key is loaded into the SSH agent, then any tempts in the future to ssh it will try to use the private key in the agent.

The following command showed me that the agent had loaded my private key:

ssh-add -l

2048 4e:a9:25:8b:05:0d:c7:a5:25:eb:5e:92:6a:e7:aa:8a roy@dell.pc (RSA)

This fingerprint will match the public key in ~/.ssh

If you reboot your machine and then log back in Gnome Keyring SSH Agent automatically loads the private key this time without asking you for the password. It will protect the private key password using login password for user account that holds the private key in ~/.ssh

You can check to verify that this is the case by running this familiar command:

ssh-add -l

But I feel unease with this feature, where Gnome Keyring SSH Agent automatically loads files in ~/.ssh, which have corresponding *.pub paired files. One solution to stop automatically loading private keys is to remove the corresponding *.pub from ~/.ssh