Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
# knot self-hosting guide
So you want to run your own knot server? Great! Here are a few prerequisites:
1. A server of some kind (a VPS, a Raspberry Pi, etc.). Preferably running a Linux of some kind.
2. A (sub)domain name. People generally use `knot.example.com`.
3. A valid SSL certificate for your domain.
There's a couple of ways to get started:
* NixOS: refer to
[flake.nix](https://tangled.sh/@tangled.sh/core/blob/master/flake.nix)
* Docker: Documented at
[@tangled.sh/knot-docker](https://tangled.sh/@tangled.sh/knot-docker)
(community maintained: support is not guaranteed!)
* Manual: Documented below.
## manual setup
First, clone this repository:
```
git clone https://tangled.sh/@tangled.sh/core
```
Then, build the `knot` CLI. This is the knot administration and operation tool.
For the purpose of this guide, we're only concerned with these subcommands:
* `knot server`: the main knot server process, typically run as a
supervised service
* `knot guard`: handles role-based access control for git over SSH
(you'll never have to run this yourself)
* `knot keys`: fetches SSH keys associated with your knot; we'll use
this to generate the SSH `AuthorizedKeysCommand`
```
cd core
export CGO_ENABLED=1
go build -o knot ./cmd/knot
```
Next, move the `knot` binary to a location owned by `root` --
`/usr/local/bin/knot` is a good choice:
```
sudo mv knot /usr/local/bin/knot
```
This is necessary because SSH `AuthorizedKeysCommand` requires [really
specific permissions](https://stackoverflow.com/a/27638306). The
`AuthorizedKeysCommand` specifies a command that is run by `sshd` to
retrieve a user's public SSH keys dynamically for authentication. Let's
set that up.
```
sudo tee /etc/ssh/sshd_config.d/authorized_keys_command.conf <<EOF
Match User git
AuthorizedKeysCommand /usr/local/bin/knot keys -o authorized-keys
AuthorizedKeysCommandUser nobody
EOF
```
Next, create the `git` user. We'll use the `git` user's home directory
to store repositories:
```
sudo adduser git
```
Create `/home/git/.knot.env` with the f…