Hosting git repositories on your VPS
To save myself some typing Iâll be using the following conventions:
A command prefixed by sysadmin$ is meant to be run in your local workstation.
A command prefixed by user@vpshost:path# is meant to be run in the vps under the specified user on the specified path.
If youâre anything like me then the first thing you do with a new VPS is set your password-less ssh login. If you havenât, hereâs how you do it:
https://gist.github.com/lacides/da055ff9ec7e2511ab14
If youâre on OSX or some other *nix without ssh-copy-id, the following one liner will work:
https://gist.github.com/lacides/8e5d06bcacb596df2fdb
To get gitolite you need to install git, on debian based systems (like ubuntu) the following command will do it:
https://gist.github.com/lacides/72b1c1d7916efc12fbfa
If you want to learn how to install git on other systems take a look at http://git-scm.com/book/en/Getting-Started-Installing-Git
From the documentation: âGitolite uses a single real (i.e., unix) user to provide secure access to git repos (...). Typically this user is git (...)â. So the first thing to do is create that user.
https://gist.github.com/lacides/e3234abbc3674fbaa832
Then, as the git user, get the code from github with:
https://gist.github.com/lacides/79f27552fd55af6eb9a4
Gitolite has a single server side command called gitolite, which can be installed running the install command that comes with the source. Running the install command using the ln flag will symlink the gitolite command to $HOME/bin (it assumes it exists). So:
https://gist.github.com/lacides/813fdb9725bc1fb2859f
Now that you have gitolite installed on your VPS, youâll need to finish the setup by running (you guessed it!) the setup command.
The setup command takes a ssh key that must not have access to the server. That means youâll need to go back to your local workstation and generate a new ssh key.
https://gist.github.com/lacides/528cc31927843d70ae2a
Donât forget to change the fileâs ownership to the git user with chown.
https://gist.github.com/lacides/efd2cc4cba1b05e41540
Now run the setup command:
https://gist.github.com/lacides/1f87b33bea424da7acfc
Gitolite comes with two repos: an empty one called testing to which all users have access and the gitolite-admin repo. The gitolite-admin repo is how you manage your gitolite server and you can pretty much do anything you want by pushing changes to it. Right now the only workstation with access to the gitolite-admin repo is the one from where gitadmin.pub came from, so go there and:
https://gist.github.com/lacides/90f317f520374c1e2de6
You can add users by putting pub keys on the keydir folder (user name is assumed to be the .pub file name), and you can manage repos and permissions by manipulating the conf/gitolite.conf file.
Take a look at http://gitolite.com/gitolite/admin.html#adminrepo and http://gitolite.com/gitolite/users.html for more details about how to manage your new gitolite server.