add git server

This commit is contained in:
ktyl 2022-04-05 01:39:56 +01:00
parent 97212dd245
commit d092f5ac0e
4 changed files with 92 additions and 19 deletions

View File

@ -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
```

6
content/gemlog/index.gmi Normal file
View File

@ -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

View File

@ -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

View File

@ -1,3 +1,6 @@
HOST = pluto
SITE = period3.xyz
deploy:
git push
ssh rhea ./deploy
ssh $(HOST) ./deploy-$(SITE)