From 5ad7734e41703116e3d1da94b7658eb4f7e9c3a4 Mon Sep 17 00:00:00 2001 From: RealStickman Date: Fri, 20 May 2022 21:24:44 +0200 Subject: [PATCH] (Grav GitSync) Automatic Commit from RealStickman --- pages/02.linux/21.gitea/default.en.md | 61 +++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 pages/02.linux/21.gitea/default.en.md diff --git a/pages/02.linux/21.gitea/default.en.md b/pages/02.linux/21.gitea/default.en.md new file mode 100644 index 0000000..0c1617e --- /dev/null +++ b/pages/02.linux/21.gitea/default.en.md @@ -0,0 +1,61 @@ +--- +title: Gitea +--- + +## Pre-Setup +Create a gitea user +`# useradd -m git` + +`# mkdir /etc/gitea` +`# chown git:git -R /etc/gitea` + +Get the user id of git with `id git` + +## Installation +Use podman to run the container +`apt install podman` + +``` +podman run --name gitea -p 3000:3000 \ + -p 127.0.0.1:2222:22 \ + -e USER_UID=1002 \ + -e USER_GID=1002 \ + -v /etc/gitea:/data \ + -v /home/git/.ssh/:/data/git/.ssh \ + -v /etc/timezone:/etc/timezone:ro \ + -v /etc/localtime:/etc/localtime:ro \ + --restart unless-stopped \ + -d docker.io/gitea/gitea:latest +``` + +The next few lines are used to set up ssh-redirection to gitea if it is used to clone a repo. +> See also the [official documentation](https://docs.gitea.io/en-us/install-with-docker/#sshing-shim-with-authorized_keys) +{.is-info} + +`$ sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key"` +`$ sudo -u git cat /home/git/.ssh/id_rsa.pub | sudo -u git tee -a /home/git/.ssh/authorized_keys` +`$ sudo -u git chmod 600 /home/git/.ssh/authorized_keys` + +``` +$ cat <<"EOF" | sudo tee /usr/local/bin/gitea +#!/bin/sh +ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@" +EOF +``` +`$ sudo chmod +x /usr/local/bin/gitea` + +We've now finished setting up the ssh-redirection. +After that, connect to the Server on port 3000 to finish the installation +The first registered user will be made admin + +## Management CLI +Gitea comes with a management cli. To access it, change into the Container first and su into the user "git". +`# podman exec -it gitea bash` +`# su git` + +### User Management +List users: +`$ gitea admin user list` + +Change user password: +`$ gitea admin user change-password -u (user) -p (password)`