Setting Up A Git Server
CREATE A USER FOR GIT
sudo adduser git
ADD KEY TO ALLOW PASSWORDLESS AUTHENTICATION
sudo su - git
mkdir .ssh
#assuming the public key was uploaded to /temp/ryan_key.pub
cat /tmp/ryan_key.pub >> ~/.ssh/authorized_keys
SET UP AN EMPTY REPO
sudo mkdir /opt/git
sudo chown git:git /opt/git
mkdir /opt/git/project.git
sudo chown git:git /opt/git/project.git
cd /opt/git/project.git
git --bare init
CLONING THE REPO
git clone git@your.server.example.com:/opt/git/project.git
LIMIT GIT USER TO GIT ACTIVITIES
Git comes with a shell 'git-shell'. We can change the git user to use this shell.
sudo vim /etc/passwd
#change git:x:1000:1000::/home/git:/bin/sh to the following
git:x:1000:1000::/home/git:/usr/bin/git-shell
COMMITTING TO THE REPO
# on Johns computer
cd myproject
git init
git add .
git commit -m 'initial commit'
git remote add origin git@gitserver:/opt/git/project.git
git push origin master
Cookbook Category: