DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Build Remote Git Repository based on SSH


Build a git repo on a Linux host based on SSH protocol according to 4.4 Git on the Server.

sudo adduser git
sudo passwd git
su git
cd
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
vi .ssh/authorized_keys          # add user's pub key, modify the comment
mkdir -p repos/avabuilder.git
cd repos/avabuilder.git/
git init --bare

So the git url is git@192.168.12.233:~/repos/avabuilder.git. Now clone this repo on the client host: git clone git@192.168.12.233:~/repos/avabuilder.git, push to this repo:

git remote add 233 git@192.168.12.233:~/repos/avabuilder.git
git push -u 233 master

The comment of a SSH pub-key is the 3rd part of the key string. As an example, for the following pub-key, the comment part is chad@myhost:

ssh-rsa AAAAB3Nza...AH8baX chad@myhost

See Add comment to existing SSH public key for details.

The problem of the method is all the users with authorized key can access all the repos.



Published

Apr 18, 2017

Last Updated

Apr 18, 2017

Category

Tech

Tags

  • git 36
  • repo 1
  • ssh 23

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor