Game of Trees daemon for Debian
===============================

To use the Game of Trees daemon to host git repositoties, a few
manual setup steps are required.  Below is an example for setting
up read only anonymous access to a clone of the upstream got repository.

First we need to check out the got source code on our host machine.

    ----------------------------------------------------------------
    # Create git directory
    $ mkdir -p /var/git
    $ cd /var/git

    # Clone repository you are planning to serve with got
    $ got clone ssh://anonymous@got.gameoftrees.org/got.git

    # Alternatively you can use git
    $ git clone --bare ssh://anonymous@got.gameoftrees.org/got.git

    # Make sure the gotd user can access the directory
    $ chown -R _gotd:_gotd /var/git
    ----------------------------------------------------------------

For our example we need to create an anonymous ssh login user and
group with an empty password to allow everyone read only access.
For a more restricted setup it is also possible to create a developer
group and users with pre-shared ssh keys.

    ----------------------------------------------------------------
    # Add anonymous user and group for ssh login
    $ addgroup anonymous
    $ adduser --disabled-password --comment "anonymous gotd login" \
      --shell /usr/bin/gotsh --ingroup anonymous anonymous
    # Make sure the password entry is actually empty and not disabled
    $ passwd -d anonymous
    ----------------------------------------------------------------

Finally it is strongly recommended to harden the anonymous user's
sshd config to make sure they can only run their gotsh shell.
In our case password authentication and empty passwords need to be
allowed explicitly.

    /etc/ssh/sshd_config.d/gotd.conf:
    ================================================================
    Match User anonymous
	DisableForwarding yes
	PermitTTY no
	PasswordAuthentication yes
	PermitEmptyPasswords yes
    ================================================================

Copy /usr/share/doc/gotd/examples/gotd.conf.example to /etc/gotd.conf and
modify it to point to our gotd git repository and allow read-only
access for the anonymous user:

    /etc/gotd.conf:
    ================================================================
    # Run as the default user
    user _gotd

    # ssh://anonymous@example.com/got
    repository "got" {
            path "/var/git/got.git"
            permit ro anonymous
    }
    ================================================================

Finally reload the sshd configuration and start the gotd service:

    ----------------------------------------------------------------
    $ systemctl reload sshd
    $ systemctl enable --now gotd
    ----------------------------------------------------------------

It should now be possible to clone the git repository with:

    ----------------------------------------------------------------
    $ got clone ssh://anonymous@example.com/got
    ----------------------------------------------------------------

You can find more information on how to configure gotsh and gotd in
their respective man pages gotsh(1), gotd(8), and gotd.conf(5).
