User Tools

Site Tools


linux:git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
linux:git [2023/03/04 14:43] rlunarolinux:git [2023/03/04 14:54] rlunaro
Line 1: Line 1:
 ====== Git ====== ====== Git ======
  
- +  [[GitServerShared|Git: create your own git server, but sharing access to all the repositories]]
-===== Intro ===== +
- +
-This turorial will show how to create a remote git server but  +
-every user you give permissions can contribute to every  +
-git project in the server.  +
- +
-To create a git server in which every project can see only the  +
-projects they have assigned, I suppose there are other solutions,  +
-but definitely this solution will not work, because in this  +
-tutorial every commit will be made by a generic git user that +
-can read and write in every directory.  +
- +
-===== Set up a git server ===== +
- +
-First, install git on your machine. In my case, because it's an  +
-ubuntu, I've run:  +
- +
-<code> +
-sudo apt-get install git  +
-</code> +
- +
-===== Create git user ===== +
- +
-I prefer to create a "normal" **git** user instead a system one.  +
-If you prefer to create a system user, just add the **--system**  +
-option to the command: +
- +
-The **--create-home** option is needed because there we will be  +
-storing the public keys of the users of the repository.  +
- +
-<code> +
-useradd --create-home --user-group git +
-</code> +
- +
-===== Enter as git user and add remote public keys ===== +
- +
-<code> +
-~$ mkdir .ssh +
-~$ chmod o=,g= .ssh +
-~$ cd .ssh +
-~/.ssh$ touch authorized_keys +
-~/.ssh$ chmod o=,g= authorized_keys +
-</code> +
- +
-===== Add the keys of the different users of the git repository ===== +
- +
- +
-<code> +
-~$ cat public_key_of_first_user.pub >> .ssh/authorized_keys +
-~$ rm public_key_of_first_user.pub # you can remove the public key afterwards if you want +
-</code> +
- +
-===== Verification: in the first_user computer check that you can log in as git user to the remote computer ===== +
- +
-Check that you can make a ssh to the remote computer with no password request:  +
- +
-<code> +
-rluna@asustao:~$ ssh git@192.168.0.21 +
-The authenticity of host '192.168.0.21 (192.168.0.21)' can't be established. +
-ED25519 key fingerprint is SHA256:PvSiThCnDq8pNOXyVgsq5vsXLME6oYIbCs0v5urvcpE. +
-This key is not known by any other names +
-Are you sure you want to continue connecting (yes/no/[fingerprint])? yes +
-Warning: Permanently added '192.168.0.21' (ED25519) to the list of known hosts. +
- +
-The programs included with the Ubuntu system are free software; +
-the exact distribution terms for each program are described in the +
-individual files in /usr/share/doc/*/copyright. +
- +
-Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by +
-applicable law. +
- +
-git@ubuntu2004:~$  +
- +
-</code> +
- +
-If this is step succeeds, you can continue.  +
- +
-==== Create a directory for your repositories ==== +
- +
-In the server computerI've created a ```/var/git``` directory +
-to hold the repositories.  +
- +
-As root, do the following: +
- +
-<code> +
-# mkdir /var/git  +
-# chown git:git /var/git +
-# chmod g=rx,o= /var/git +
-</code> +
- +
-The permissions are set 750 to allow the git user to do  +
-anything inside the directory, and the group members to  +
-allow other users to read the contents: this will allow  +
-us to create other users that can read this directory +
-by adding them to the group of the git user.  +
- +
-==== Create a repository ==== +
- +
-To create a repository, log in as the git user and make  +
-a git init --bare: +
- +
-<code> +
-git$ cd /var/git +
-git$ mkdir repo1.git +
-git$ cd repo1.git +
-git$ git init --bare +
-</code> +
- +
-Congrats! you have created your first repository.  +
-The .git extension of the directory is not needed, is +
-just to make the url of the repository more cool.  +
- +
- +
- +
- +
- +
- +
- +
- +
-<code> +
-usermod --shell /bin/false git +
-</code>+
  
  
  
linux/git.txt · Last modified: 2023/03/04 14:55 by rlunaro