From 7939805687e75f8a46cd6c43a80e9fb3db88da81 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Mon, 7 Mar 2022 21:18:44 +0000 Subject: Add Installing Docker on Arch Linux --- .../git/2021-05-29/setting-up-a-self-host-git-server/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'www/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html') diff --git a/www/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html b/www/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html index 662017b..39c89dd 100644 --- a/www/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html +++ b/www/posts/git/2021-05-29/setting-up-a-self-host-git-server/index.html @@ -18,7 +18,7 @@ -

Setting up a Self Hosted Git Server

Sat 29th May 2021 By David T. Sadler.

I've always liked the idea of self hosting some of my git repositories. After a bit of research I found that it involves.

Installing Git

Since its an Ubuntu server installing git is as simple as.

$ sudo apt install git-core

Creating a User

The git user will serve two purposes.

$ sudo adduser --system --shell /usr/bin/git-shell --group --disabled-password --home /home/git git

Setting up SSH

On my local machine git will use ssh to connect to the remote server as the git user. In order to do this I will need to copy my public ssh key to the git user account.

The below commands create the required .ssh directory and authorized_keys file with the correct permissions.

$ sudo mkdir /home/git/.ssh
+        

Setting up a Self Hosted Git Server

Sat 29th May 2021 By David T. Sadler.

I've always liked the idea of self hosting some of my git repositories. After a bit of research I found that it involves.

  • Installing git.
  • Creating a git user.
  • Setting up ssh so that I can log into the sever securely as the git user.
  • Creating a test repository on the server.
  • Creating a test project on my local machine.
  • Pushing the test project to the git sever.

Installing Git

Since its an Ubuntu server installing git is as simple as.

$ sudo apt install git-core

Creating a User

The git user will serve two purposes.

  • The repositories will be stored in the user's home directory.
  • The user account will contain the public ssh keys of remote users that can access the repositories.
$ sudo adduser --system --shell /usr/bin/git-shell --group --disabled-password --home /home/git git
  • --system Creates a system user user. Not strictly required but since this is not a normal user account I prefer to use this option.
  • --shell /usr/bin/git-shell Restrict the git user to only git related activities. This also prevents remote users from obtaining a shell by logging in via ssh. Note that git-shell does not prevent normal git operations, such as pull and push, from working over ssh.
  • --group Creates a group that is the same name as the user.
  • --disabled-password Prevent logging in with a password. The use of ssh keys is still allowed.
  • --home /home/git The home directory for the user.

Setting up SSH

On my local machine git will use ssh to connect to the remote server as the git user. In order to do this I will need to copy my public ssh key to the git user account.

The below commands create the required .ssh directory and authorized_keys file with the correct permissions.

$ sudo mkdir /home/git/.ssh
 $ sudo chown git:git /home/git/.ssh
 $ sudo chmod 700 /home/git/.ssh
 $ sudo touch /home/git/.ssh/authorized_keys
@@ -41,10 +41,10 @@ $ cd test
 $ git init
 $ touch readme
 $ git add .
-$ git commit -m 'Initial commit'
+$ git commit -m 'Initial commit'
 $ git remote add origin git@git.davidtsadler.com:test.git
 $ git push origin main

I can also test that I can clone the repository.

rm -rf test
-git clone git@git.davidtsadler.com:test.git

Links

Git - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
+git clone git@git.davidtsadler.com:test.git

Links

Git - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
-- cgit v1.2.3-13-gbd6f