From d092f5ac0efadbec5ccc964aafabf2aa860e9a14 Mon Sep 17 00:00:00 2001 From: ktyl Date: Tue, 5 Apr 2022 01:39:56 +0100 Subject: [PATCH] add git server --- content/gemlog/2022/04/05/git-server.gmi | 76 ++++++++++++++++++++++++ content/gemlog/index.gmi | 6 ++ content/index.gmi | 24 ++------ makefile | 5 +- 4 files changed, 92 insertions(+), 19 deletions(-) create mode 100644 content/gemlog/2022/04/05/git-server.gmi create mode 100644 content/gemlog/index.gmi diff --git a/content/gemlog/2022/04/05/git-server.gmi b/content/gemlog/2022/04/05/git-server.gmi new file mode 100644 index 0000000..ced6b7b --- /dev/null +++ b/content/gemlog/2022/04/05/git-server.gmi @@ -0,0 +1,76 @@ +=> ../../../index.gmi Index + +=> https://git-scm.com/ Git [www] + +# A minimal Git server + +Sometimes hosted services aren't the right fit for the job. Here are some basic steps for setting up and using remote Git repositories on a remote Debian host. You will need sudo access. + +## Create a Git User + +Add a user to own the repositories: + +``` +sudo adduser git +``` + +Start a session for the new user in their home directory: + +``` +sudo su -l git +``` + +## Configure SSH access + +Create the `.ssh` directory and make it readable only to the new user. + +``` +mkdir ~/.ssh +chmod 700 ~/.ssh +``` + +Create an `authorized_keys` file in the `.ssh` directory, and make it accessible only to the new user. + +``` +touch .ssh/authorized_keys +chmod 600 `.ssh/authorized_keys` +``` + +Create a public/private key pair locally to authenticate a user when connecting to the remote host. + +``` +ssh-keygen -t rsa +``` + +Copy the key into the (remote) git user's `.ssh/authorized_keys`, for example using `ssh-copy-id` or by giving the public key to the server administrator. + +Add an entry to your local `.ssh/config`: + +``` +Host myhost + HostName chaos.period3.xyz + User git + IdentityFile ~/.ssh/id_rsa +``` + +Test the configuration with: + +``` +ssh myhost +``` + +## Create a bare repository + +Create directories within the git user's home directory (nested paths are allowed). Conventionally Git repositories use a `.git` suffix, for example `my-projects/my-repo.git` or just `my-repo.git`. + +``` +git init --bare repo.git +``` + +There now exists an empty Git repository on the host. The remote can be added to a local repository: + +``` +git remote add origin git@host:my-repo.git +git push -u origin main +``` + diff --git a/content/gemlog/index.gmi b/content/gemlog/index.gmi new file mode 100644 index 0000000..020efd3 --- /dev/null +++ b/content/gemlog/index.gmi @@ -0,0 +1,6 @@ +=> ../index.gmi Home + +Technical notes mostly but maybe some other stufflater + +=> ./2022/04/05/git-server.gmi 2022-04-05 A minimal Git server + diff --git a/content/index.gmi b/content/index.gmi index fc49ad4..f99f919 100644 --- a/content/index.gmi +++ b/content/index.gmi @@ -1,21 +1,3 @@ - - -``` - _____ - _ __|___ / -| '_ \ |_ \ -| |_) |__) | -| .__/____/ -|_| -``` - -a constant ramble of varying intensity - -=> ./books/index.gmi books -=> ./thoughts.gmi thoughts -=> ./reference.gmi reference - - ``` _________ . . (.. \_ , |\ /| @@ -28,3 +10,9 @@ a constant ramble of varying intensity |/ \_ \| / \________/ ``` + +=> ./gemlog/index.gmi Gemlog +=> ./books/index.gmi Books +=> ./thoughts.gmi Thoughts +=> ./reference.gmi Reference + diff --git a/makefile b/makefile index 733eab9..4c2d42f 100644 --- a/makefile +++ b/makefile @@ -1,3 +1,6 @@ +HOST = pluto +SITE = period3.xyz + deploy: git push - ssh rhea ./deploy + ssh $(HOST) ./deploy-$(SITE)