1. Setup a Ubuntu EC2 server instance in https://console.aws.amazon.com/ec2.
In my case, I’ve setup Ubuntu 12.04 64Bit Server with m1.small instance type.
2. Make a .ssh directory in your local machine home directory and Copy your EC2 pem file into your home directory:
cd
mkdir .ssh
cd .ssh
cp /path/pemfile.pem /home/username/.ssh
3. Get the EC2 server instance login and create a SSH config file to access to EC2 instance:
Create a new file “~/.ssh/config” which contains your Amazon EC2 hostname, user and PEM key location.
nano config
Host git
Hostname EC2PublicDNS
User ubuntu
IdentityFile /home/username/.ssh/pemfile.pem
With this configuration, we can login into EC2 server instance with:
ssh git
exit
4. Back to local machine, generate and copy your SSH public key into EC2 server instance:
ssh-keygen -t rsa
cp ~/.ssh/id_rsa.pub /tmp/username.pub
rsync -avr /tmp/username.pub -e "ssh -i /home/username/.ssh/pemfile.pem" ubuntu@EC2PublicDNS:/tmp/username.pub
5. Login into EC2 instance and Change username.pub file permission:
ssh git
chmod 766 /tmp/username.pub
6. Install gitolite in EC2 server instance:
sudo apt-get install git gitolite git-daemon-run
Create new git account for gitolite and grant our local machine access into EC2 instance:
sudo adduser --system --shell /bin/bash --gecos 'git version control' --group --disabled-password --home /home/git git
sudo su - git
cd /home/git
echo "PATH=$HOME/bin:$PATH" > .bashrc
gl-setup /tmp/username.pub
Change umask setting in /home/git/gitolite.rc
$REPO_UMASK = 0027;
7. Back to your local machine. Try Clone gitolite-admin repo:
eval `ssh-agent`
ssh-add
cd
git clone git@git:gitolite-admin.git