Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup git repository on a server with ssh access

Tags:

git

Following the instructions in this link I managed to create a repository on my $HOME on the uni's server. I clone/pull/push to this repository on the server using SSH.

My question is: Is it possible to grant access to someone else to clone/push/pull from this repository? Obviously I do not have root privileges on the server side. Furthermore, I don't want to have it as a public repository... I want to know who is cloning and pushing to this one.

Can I do something like that on the web-storage part of my account? Where my wesite is stored, and then use something like htaccess to manage access?

like image 563
Dror Avatar asked Nov 12 '22 10:11

Dror


1 Answers

You could set POSIX ACLs on the repository, to allow more users to access it. But that won't guarantee somebody commits as another user / it's quite cumbersome to configure / ...

Instead, I suggest you to use gitolite: https://github.com/sitaramc/gitolite.

It works in a way very similar to the pull/push mechanism on github: one ssh user, a custom shell that authenticates the user depending on the ssh key that was used to login.

If you want something more complex (github-like, with a web UI providing lots of features), have a look at gitlab (http://gitlabhq.org/) or gitorious (http://getgitorious.com/).

Update

In order to be able to login normally on the server as the user in which you installed gitolite:

  • Create a new SSH key and keep it, let's say, as ~/.ssh/id_rsa-git_admin on your workstation
  • Add it as the first key in the ~/.ssh/authorized_keys file on the machine
  • Install gitolite and make sure the key is still there (wait before logging out)
  • From another terminal, run a git clone git@yourhost:gitolite-admin, and make sure it works.
  • From another termina, try to login on the machine with ssh -i ~/.ssh/id_rsa-git_admin git@yourhost

If the last two steps are ok, your installation is fine.

like image 150
redShadow Avatar answered Nov 15 '22 04:11

redShadow