GitServer: Unterschied zwischen den Versionen

Aus Info-Theke
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „Kategorie:ServerApplikation == Initialisierung == <pre> adduser git su git cd mkdir .ssh cd .ssh touch authorized_keys </pre>“)
 
 
(10 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 3: Zeile 3:
== Initialisierung ==
== Initialisierung ==


<pre>
<syntaxhighlight lang="bash">
adduser git
adduser --shell /usr/bin/git-shell git
su git
cd /home/git
 
cd
mkdir .ssh
mkdir .ssh
cd .ssh
cd .ssh
touch authorized_keys
touch authorized_keys
chown -R git.git /home/git
</syntaxhighlight>
* /home/git/.ssh/authorized_keys
<pre>
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/Z4t...0blnUDBCr8AEZIj hm@ant
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDH6ej...hrCjPpDy+U1L0W3 hm@mint18.fn.local
</pre>
== Leeres Repository einrichten: ==
<pre>
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
</pre>
== Zugriff ==
<pre>
git clone ssh://git@git.hamatoma.de:/home/git/repo/oo4f.git
</pre>
= GitWeb =
<syntaxhighlight lang="bash">
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
</syntaxhighlight>
* /etc/gitweb.conf
<pre>
$projectroot = "/home/git/repo";
our @git_base_url_list = qw(git://gitweb.hamatoma.de https://git@gitweb.hamatoma.de);
</pre>
</pre>

Aktuelle Version vom 17. November 2024, 16:14 Uhr


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);