···
git clone https://tangled.sh/@tangled.sh/core
-
Then, build our binaries (you need to have Go installed):
-
* `knotserver`: the main server program
-
* `keyfetch`: utility to fetch ssh pubkeys
-
* `repoguard`: enforces repository access control
-
go build -o knot ./cmd/knotserver
-
go build -o keyfetch ./cmd/keyfetch
-
go build -o repoguard ./cmd/repoguard
-
Next, move the `keyfetch` binary to a location owned by `root` --
-
`/usr/local/libexec/tangled-keyfetch` is a good choice:
-
sudo mv keyfetch /usr/local/libexec/tangled-keyfetch
-
sudo chown root:root /usr/local/libexec/tangled-keyfetch
-
sudo chmod 755 /usr/local/libexec/tangled-keyfetch
-
This is necessary because SSH `AuthorizedKeysCommand` requires [really specific
-
permissions](https://stackoverflow.com/a/27638306). Let's set that up:
sudo tee /etc/ssh/sshd_config.d/authorized_keys_command.conf <<EOF
-
AuthorizedKeysCommand /usr/local/libexec/tangled-keyfetch
AuthorizedKeysCommandUser nobody
-
Next, create the `git` user:
-
Copy the `repoguard` binary to the `git` user's home directory:
-
sudo cp repoguard /home/git
-
sudo chown git:git /home/git/repoguard
-
Now, let's set up the server. Copy the `knot` binary to
-
`/usr/local/bin/knotserver`. Then, create `/home/git/.knot.env` with the
-
following, updating the values as necessary. The `KNOT_SERVER_SECRET` can be
-
obtaind from the [/knots](/knots) page on Tangled.
KNOT_REPO_SCAN_PATH=/home/git
···
If you run a Linux distribution that uses systemd, you can use the provided
service file to run the server. Copy
-
[`knotserver.service`](https://tangled.sh/did:plc:wshs7t2adsemcrrd4snkeqli/core/blob/master/systemd/knotserver.service)
to `/etc/systemd/system/`. Then, run:
···
KNOT_REPO_SCAN_PATH=/home/git/repositories
-
In your SSH config (e.g. `/etc/ssh/sshd_config.d/authorized_keys_command.conf`),
-
update the `AuthorizedKeysCommand` line to use the new folder. For example:
-
AuthorizedKeysCommand /usr/local/libexec/tangled-keyfetch -git-dir /home/git/repositories
-
AuthorizedKeysCommandUser nobody
-
Make sure to restart your SSH server!
-
The keyfetch executable takes multiple arguments to change certain paths. You
-
can view a full list by running `/usr/local/libexec/tangled-keyfetch -h`.
-
As an example, if you wanted to change the path to the repoguard executable,
-
you would edit your SSH config (e.g. `/etc/ssh/sshd_config.d/authorized_keys_command.conf`)
-
and update the `AuthorizedKeysCommand` line:
-
AuthorizedKeysCommand /usr/local/libexec/tangled-keyfetch -repoguard-path /path/to/repoguard
AuthorizedKeysCommandUser nobody
Make sure to restart your SSH server!