Wednesday, February 2, 2011

Root login to Amazon EC2 instance

Login to fresh EC2 instance as root can return error: "Please login as the ec2-user user rather than root user". You can login easily as "ec2-user" and execute administration commands using "sudo ..." or just become root using "sudo su". But it's not always comfortable and if you want to login via SSH as root, follow these simple steps.
  1. Edit the /etc/ssh/sshd_config file and change the line that says "PermitRootLogin No" to "PermitRootLogin without-password". Then restart the sshd server with "service sshd restart". Be careful, if you screw up the sshd file, it is possible you will only have your current ssh session to fix it, so always test any changes with a second session.
  2. Edit the /root/.ssh/authorized_keys file. The first (and only) entry starts with "command ... sleep 10; ssh-rsa [big long key]". If you remove the text from the beginning of the line until where it says "ssh-rsa", you will be able to login as root via SSH with your Amazon keypair.

Tuesday, February 1, 2011

Bzr to Git Migration

The migration from Bzr to Git is very simple, though it's not obvious. We found that Git is faster on pushing to (and pulling from) remote repositories. This is the only reason why we migrate some projects from Brz to Git. As for any other aspects — we are just happy with Bzr.

Well, I suppose you work on Linux.

1. Install bzr fastimport plugin:
> mkdir -p ~/.bazaar/plugins
> cd ~/.bazaar/plugins
> bzr clone lp:bzr-fastimport fastimport
2. Install python package required by fastimport plugin:
> cd ~
> bzr clone lp:python-fastimport
> cd python-fastimport
> ./setup.py install (need root privileges here)
3. Now we can export bzr repository to git:
> cd my-bzr-repos
> git init
> bzr fast-export --plain . | git fast-import
> rm -rf .bzr
> git reset --hard
Here it is.