Workstation setup
#Install ssh
$sudo apt-get install openssh-server
#Install git-core
$sudo apt-get install python-software-properties
$sudo add-apt-repository ppa:git-core/ppa
$sudo apt-get update
$sudo apt-get install git
$git config --global user.email "Email"
$git config --global user.name "Your Name"
$ssh-keygen -t rsa (and rename ~/.ssh/id_rsa.pub to YourName.pub )
#send YourName.pub to the person which have admin rights to the git server
$git config --global user.email "Email"
$git config --global user.name "Your Name"
$ssh-keygen -t rsa (and rename ~/.ssh/id_rsa.pub to YourName.pub )
#send YourName.pub to the person which have admin rights to the git server
Git Server Setup
#Adduser git
$sudo useradd git
#edit /etc/sudoers, add user 'git' as sudoer
#Install ssh
$sudo apt-get install openssh-server
#Install git-core
$sudo apt-get install python-software-properties
$sudo add-apt-repository ppa:git-core/ppa
$sudo apt-get update
$sudo apt-get install git
#Install gitolite
Make sure ~/.ssh/authorized_keys is empty or non-existent
Run this from your workstation (this workstation will have admin rights of the git server)
$ssh-keygen -t rsa (and rename ~/.ssh/id_rsa.pub to YourName.pub )
copy the ssh public key from your workstation to git server $HOME/YourName.pub
Run the following commands:
git clone git://github.com/sitaramc/gitolite
mkdir -p $HOME/bin
gitolite/install -to $HOME/bin
gitolite setup -pk YourName.pub
If the last command doesn't run perhaps 'bin' in not in your 'PATH'.
You can either add it (add this line to ~/.bashrc), or just run:
$HOME/bin/gitolite setup -pk YourName.pub
Adding Users and repos
Do NOT add new repos or users manually on the server. Gitolite users, repos, and access rules are maintained by making changes to a special repo called 'gitolite-admin' and pushing those changes to the server.To administer your gitolite installation, start by doing this on your workstation, which this workstation have added public key to git server and have RW access rights to 'gitolite-admin' repo
$git clone git@host:gitolite-admin
**NOTE**: if you are asked for a password, something has gone wrong.
(check if this workstation's ssh public key is added to the git server or not)
Now if you 'cd gitolite-admin', you will see two subdirectories in it: 'conf' and 'keydir'.
To add new users alice, bob, and carol, obtain their public keys and add them to 'keydir' as alice.pub, bob.pub, and carol.pub respectively.
To add a new repo 'foo' and give different levels of access to these
users, edit the file 'conf/gitolite.conf' and add lines like this:
repo foo
RW+ = alice
RW = bob
R = carol
See the 'ACCESS RULES' section later for more details.
Once you have made these changes, do something like this:
$git add conf
$git add keydir
$git commit -m 'added foo, gave access to alice, bob, carol'
$git push
When the push completes, gitolite will add the new users to ~/.ssh/authorized_keys on the server, as well as create a new, empty, repo called 'foo'.
Install gitweb
$apt-get install apache2 gitweb
$sudo vim /etc/gitweb.conf
change $projectroot to /home/git/repositorieschange $projects_list to /home/git/projects.list
$chmod g+r /home/git/projects.list
$chmod -R g+rx /home/git/repositories
$sudo vim /home/git/.gitolite.rc
# change $REPO_UMASK = 0077; to $REPO_UMASK = 0027; # gets you 'rwxr-x---'
#add authentication to the web
$sudo htpasswd -cb /etc/appach2/gitweb.htpasswd ID PASSWD
$sudo vim /etc/apache2/conf.d/gitweb
Alias /gitweb /usr/share/gitweb<Directory /usr/share/gitweb>Options FollowSymLinks +ExecCGIAddHandler cgi-script .cgiAuthUserFile /etc/apache2/gitweb.htpasswdAuthName "GitWeb"AuthType Basicrequire valid-user</Directory>
$sudo /etc/init.d/apache2 restart #restart to take effect
沒有留言:
發佈留言