I’m using Ubuntu 12.04 version but this doesn’t means that these instructions won’t run with other versions, since is an openssh process well tested during years on unix systems.
First step is to be sure that we have all required software: OpenSSH and git-core. The openssh-client should be installed by default in Ubuntu:
apt-get install git-core openssh-client
Second step is generate your SSH keys as you can read at this article from Ubuntu Help. Make a backup of your actual keys (if you have), since if you delete private keys, are impossible to regenerate them later:
mv ~/.ssh ~/_ssh_back
Then, you can create the directory and generate keys:
chmod 700 ~/.ssh
ssh-keygen -t rsa -C “firstname.lastname@example.org”
This will ask you for the passphrase, which will be asked always you add a private ssh key to a new system.
Generating public/private rsa key pair.
Enter file in which to save the key (/home/b/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/b/.ssh/id_rsa.
Your public key has been saved in /home/b/.ssh/id_rsa.pub.
Now you have your public (~/.ssh/id_rsa.pub) and private keys (~/.ssh/id_rsa). If you want to begin to work now, before rebooting your system, you’ll need to add the private key to the system:
If you don’t do this, could result in error when you try to connect to git server later, as you can see here.
After this point you can send your public key (~/.ssh/id_rsa.pub) to your git-server provider to give you permissions in your repos. For example, in GitHub, you have to paste the public key file content into your account settings, as you can see here.
At this point you have to set your user name and email for commit messages:
git config –global user.name ‘John Doe’
git config –global user.email email@example.com
Once your git-server-provider gives you the permissions, you can do a simply test to see which permissions you have:
> ssh -T firstname.lastname@example.org
hello hwtest, this is gitolite 2.2-1 (Debian) running on git 18.104.22.168
the gitolite config gives you the following access:
R W testing
Now, you can enjoy git: clone, commit, push, pull,…. Take a look at this cheatsheet. i.e.:
git clone email@example.com:testing.git