From eb72c5fc46b460aefcdb955d78343a99f9d8139b Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Fri, 30 Sep 2022 16:04:11 +0200 Subject: [PATCH] Little bit of polish --- content/rambles/git-server.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/content/rambles/git-server.md b/content/rambles/git-server.md index b7daebe..467b1ed 100644 --- a/content/rambles/git-server.md +++ b/content/rambles/git-server.md @@ -3,7 +3,7 @@ title: 'Hosting your own Git "server"' date: "2022-09-30T14:27:31+02:00" author: "$HUMANOID" tags: ["git", "ssh"] -description: "The basis of a Git server is a machine accessible in a way that git understands with a bunch of bare git repositories" +description: "The basis of a Git server is a machine accessible in a way that Git understands with a bunch of bare repositories" toc: true --- @@ -51,7 +51,7 @@ ssh-keygen -t ed25519 -f ~/.ssh/ ``` I also recommend creating an entry in `~/.ssh/config` for your Git server: ```ssh_config -Host +Host -git Hostname User git Identityfile ~/.ssh/ @@ -59,7 +59,8 @@ Host ### Server side Next step is to make the `git` account accessible over SSH. -To do this, log in as the `git` user and create a `.ssh` directory with an `authorized_keys` file with the public half of the `` keypair: +`ssh-copy-id` won't work because the `git` user doesn't have a password. +So instead, log in as the `git` user and create a `.ssh` directory with an `authorized_keys` file with the public half of the `` keypair: ```sh sudo su - git umask 077 # strict read write permissions @@ -83,13 +84,13 @@ That's it. You now have a Git "server" with a repo named ``. -To add something to this repo, on your client machine create a new repository and add `:/srv/git/.git` as remote and push your project to it. +To add something to this repo, on your client machine create a new repository and add `-git:/srv/git/.git` as remote and push your project to it. Common practice dictates that this remote be called `origin`: ```sh mkdir my-fancy-project cd my-fancy-project git init -git remote add origin :/srv/git/.git +git remote add origin -git:/srv/git/.git echo "# Self-hosted repo!" > README.md git add -A git commit -m "Initial commit" @@ -98,7 +99,7 @@ git push -u origin main # assuming you use main as your default branch name To clone this repository on another machine, add the `` SSH keypair and related configuration section in `~/.ssh/config` so said machine and run: ```sh -git clone :/srv/git/.git +git clone -git:/srv/git/.git ``` # Automation