Set up authentication automatically

This commit is contained in:
Manuel Thalmann 2024-12-11 04:17:48 +01:00
parent 27c9d64564
commit f0082107ef

View file

@ -49,6 +49,8 @@ begin
set -l file (mktemp)
set -l root (getServiceRoot $argv)
set -l home /srv/git
set -l sshDir "$home/.ssh"
set -l keyFile "$sshDir/id_rsa"
set -l dir "$root/data"
set -l bin /usr/local/bin/forgejo
set -l config "$root/docker-compose.base.yml"
@ -71,12 +73,16 @@ begin
yq "$envKey.USER_GID = $gid" |
sudo tee "$config" >/dev/null
rm "$file"
and sudo mkdir -p "$dir"
and sudo mkdir -p "$home"
and sudo chown -R $uid:$gid "$dir"
and sudo chown -R $uid:$gid "$home"
and sudo -u "#$uid" mkdir -p ~"$user"/.ssh
rm "$file"
and sudo -u "#$uid" mkdir -p "$sshDir"
and sudo -u "#$uid" ssh-keygen -t rsa -b 4096 -C "Forgejo Host Key" -f "$keyFile" -N ""
and sudo -u "#$uid" cat "$keyFile.pub" | sudo -u "#$uid" tee -a "$sshDir/authorized_keys"
and sudo chmod 600 "$sshDir/authorized_keys"
set port (yq (getSSHPortKey) "$overrides" | extractPort)