Home > Uncategorized > AWS Git Repository with Alestic Gitolite

AWS Git Repository with Alestic Gitolite

I will be using the Alestic Gitolite AIM ami-b0d309d9. This is not the Marketplace AWS located here, it looks like the Market place version does not qualify for the free tier.

The Alestic Git Server aim was taken directly from the documentation. Using the ami directly when creating the instance allows for the free tier pricing.

ec2-run-instances --key $USER  --instance-type t1.micro ami-b0d309d9

Create a new Instance, use the Community AMI ami-b0d309d9. When searching for ami-b0d309d9 the Marketplace version will show up also, select ami-b0d309d9 directly. Note, when a new version is released the ami number will change, check the documentation link above for the new ami number.

I always select a particular zone, the reason is because volumes are not available across zones and I like to keep all my data in one area.

Alestic recommends uploading your own ssh pub key for use when creating the instance, and this is a good pratice and this does make accessing your instances easier if you are running a Linux workstation. However I’m running Windows, so I create a new key for each instance and store them locally on my NAS. I use PuTTY and simply reference the individual key for each insance.

I also find it a good pratice to create a security group for each individual instance. The reason is you can not change the security group for an instance, only change the open ports. If I have two instances using the same security group and I need to open a port for one instance it will be opened for both instances if they share the same group. Therefore, don’t use the default group, create a new one, or reuse an existing one specific for your Git server.

After creating the instance, I always verify the Name tags for both the instance itself and the volume, naming the volume something such as “Git System”.

Create an Elastic IP and associate it with your instance. Create a DNS entry from your provider for this ip for easy access such as “git.mycompany.com”.

Log into your new Git server and lets begin configuration. When you SSH to the server you must specify the key used when creating the instance. The login username will be ‘ubuntu’ as is true for all Canonical Ubuntu AWS instances.

I like to use the ubuntu account to initially configure the gitolite-admin repository. However, if you try to clone the repository you will receive an error. The problem is the ubuntu user does not have id_rsa/id_rsa.pub files in .ssh.

Upload the ssh key used when creating the instance to /home/ubuntu/.ssh/id_rsa . I use puttygen to extract the public key from the private key, then upload this file to /home/ubuntu/.ssh/id_rsa.pub. I use WinSCP to perform the upload. Once uploaded, you will need to update the key permissions:

chmod 600 id_rsa
chmod 644 id_rsa.pub

Gitolite was initialized to allow access only from the key used to create this instance. The ubuntu account will now use this key and you can clone the gitolite-admin repository. I usually create a Git folder under the ubuntu home directory:

mkdir Git
cd Git
git clone git@[your server name, dns, ip, or localhost]:gitolite-admin

Now we can add a user. This is as easy as simply placing the users public key in the gitolite-admin/keydir folder. You will see already in this folder is the public key of the key used to create this instance. The same private/public rsa keys we placed in the ubuntu .ssh folder earlier, granting us access to the repository.

Adding a repository is also quite easy. Simply edit the gitolite-admin/conf/gitolite.conf file. Here’s my default values:

repo gitolite-admin
    RW+     =   Git
    RW+     =   mike

repo testing
    RW+     =   @all

repo Project1
    RW+     =   mike

I’ve added mike.pub to the keydir and can now grant that key RW+ access to the gitolite-admin repository. I’ve also added a new repository called Project1 and granted mike RW+.

Push the changes to the git server to make them take effect, from the gitolite-admin folder:

git add .
git commit -m "initial configuration"
git push origin master

See my next post Creating AWS Git Repository Volume to create a seperate volume to hold your Git repositories.

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: