Sunday, June 19, 2011

Setup Bitbucket using SSH on Ubuntu

Bitbucket is a good alternate to Github which provides free unlimited private hosting upto 5 collaborators. It uses Mercurial which is DVCS.

I prefer SSH over HTTP to access work on my repository. The steps to setup are as follows:
  1. Signup on Bitbucket (Obviously)
  2. Create a repository after login using Repository -> Create New Repository
  3. Install mercurial on your local system
    1. sudo apt-get install mercurial
  4. Create the Mercurial Configuration File
    1. vi ~/.hgrc
    2. [ui]
      editor = vi
      username = FIRST_NAME LAST_NAME <email>
      
  5. Create SSH Key if not present on your local system  using the following steps
    1. ssh-keygen
    2. The generated key files are stored under ~/.ssh
  6. Upload the ~/.ssh/id_rsa.pub file to Bitbucket under Account -> SSH Keys
  7. Setup the Key in Ubuntu
    1. chmod 644 ~/.ssh/id_rsa.pub
      ssh-agent bash
      ssh-add
  8. Now clone the repository from remote server
    1. hg clone ssh://hg@bitbucket.org/<username>/<repository>
  9. To add and commit code use the following commands
    1. hg add <file/folder>
      hg commit -m '<commit message>'
      hg push
     
    A very good reference for basic Mercurial is
http://hgbook.red-bean.com/read/mercurial-in-daily-use.html
     


    Thursday, June 9, 2011

    Generate ssh keys

    By default ssh-keygen generates a RSA private/public key pair.

    To generate a DSA Key

    ssh-keygen -t dsa -b 1024 

    The option -t is for the type of encryption (dsa/rsa)
    The option -b is for the number of bits for encryption (1024,2048 etc)

    Tuesday, April 26, 2011

    Get the previous date in month-dd-yyyy formation in unix

    Another nifty command in Bash to do so in the required format of month-dd-yyyy

    date -d 'yesterday' +%B-%d-%G
    

    Other Formats are mentioned at http://unixhelp.ed.ac.uk/CGI/man-cgi?date

    Monday, December 20, 2010

    The first post of the day

    Who am i? Why do I write here? Who cares?

    Its so weird that the world has connected people in such weird ways.
    When you are reading this you have no idea who or where am I? Its like putting a letter inside a bottle and throw it in the ocean hoping that someday someone will read it. This will be place maybe where I could just express my thoughts as and when they come. They will be in no particular order or related to specific topic.