GitServer

Aus Info-Theke
Version vom 17. November 2024, 16:14 Uhr von Hamatoma (Diskussion | Beiträge) (→‎Zugriff)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen


Initialisierung[Bearbeiten]

adduser --shell /usr/bin/git-shell git
cd /home/git
mkdir .ssh
cd .ssh
touch authorized_keys
chown -R git.git /home/git
  • /home/git/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/Z4t...0blnUDBCr8AEZIj hm@ant
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDH6ej...hrCjPpDy+U1L0W3 hm@mint18.fn.local

Leeres Repository einrichten:[Bearbeiten]

mkdir /home/git/repo
chown git.git /home/git/repo

PROJ=example
DIR=/home/git/repo/$PROJ.git
mkdir $DIR
cd $DIR
git --bare init
chown -R git.git $DIR
touch $PROJ.git/git-daemon-export-ok
echo "Short project's description" > $PROJ.git/description

Zugriff[Bearbeiten]

git clone ssh://git@git.hamatoma.de:/home/git/repo/oo4f.git

GitWeb[Bearbeiten]

apt install gitweb fcgiwrap
DOMAIN=gitweb.hamatoma.de
FN=/etc/nginx/sites-available/$DOMAIN
test -e $FN || cat <<EOS >$FN
server {
  listen 80;
  include snippets/letsencrypt.conf;
  server_name $DOMAIN;
  root /usr/share/gitweb;
  location / {
    return 301 https://$server_name$request_uri;  # enforce https
  }
}
server {
  listen 443 ssl http2;
  server_name $DOMAIN;
  ssl_certificate     /etc/letsencrypt/live/latest/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/latest/privkey.pem;
  #ssl_certificate /etc/ssl/certs/$DOMAIN.pem;
  #ssl_certificate_key /etc/ssl/private/$DOMAIN.key;
  access_log /var/log/nginx/a_gitweb.log;
  error_log /var/log/nginx/e_gitweb.log;
  location /index.cgi {
    root /usr/share/gitweb/;
    include fastcgi_params;
    gzip off;
    fastcgi_param SCRIPT_NAME \$uri;
    fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
  }
  location / {
    root /usr/share/gitweb/;
    index index.cgi;
  }
}
EOS
ln -s ../sites-available/$DOMAIN /etc/nginx/sites-enabled/$DOMAIN
MkCert.sh $DOMAIN
  • /etc/gitweb.conf
$projectroot = "/home/git/repo";
our @git_base_url_list = qw(git://gitweb.hamatoma.de https://git@gitweb.hamatoma.de);