···6677Read the introduction to Tangled [here](https://blog.tangled.sh/intro).
8899-## knot self-hosting guide
1010-1111-So you want to run your own knot server? Great! Here are a few prerequisites:
1212-1313-1. A server of some kind (a VPS, a Raspberry Pi, etc.). Preferably running a Linux of some kind.
1414-2. A (sub)domain name. People generally use `knot.example.com`.
1515-3. A valid SSL certificate for your domain.
1616-1717-There's a couple of ways to get started:
1818-* NixOS: refer to [flake.nix](https://tangled.sh/@tangled.sh/core/blob/master/flake.nix)
1919-* Docker: Documented below.
2020-* Manual: Documented below.
2121-2222-## docker setup
2323-2424-Clone this repository:
2525-2626-```
2727-git clone https://tangled.sh/@tangled.sh/core
2828-```
2929-3030-Modify the `docker/docker-compose.yml`, specifically the
3131-`KNOT_SERVER_SECRET` and `KNOT_SERVER_HOSTNAME` env vars. Then run:
3232-3333-```
3434-docker compose -f docker/docker-compose.yml up
3535-```
3636-3737-### manual setup
3838-3939-First, clone this repository:
4040-4141-```
4242-git clone https://tangled.sh/@tangled.sh/core
4343-```
4444-4545-Then, build our binaries (you need to have Go installed):
4646-* `knotserver`: the main server program
4747-* `keyfetch`: utility to fetch ssh pubkeys
4848-* `repoguard`: enforces repository access control
4949-5050-```
5151-cd core
5252-export CGO_ENABLED=1
5353-go build -o knot ./cmd/knotserver
5454-go build -o keyfetch ./cmd/keyfetch
5555-go build -o repoguard ./cmd/repoguard
5656-```
5757-5858-Next, move the `keyfetch` binary to a location owned by `root` --
5959-`/usr/local/libexec/tangled-keyfetch` is a good choice:
6060-6161-```
6262-sudo mv keyfetch /usr/local/libexec/tangled-keyfetch
6363-sudo chown root:root /usr/local/libexec/tangled-keyfetch
6464-sudo chmod 755 /usr/local/libexec/tangled-keyfetch
6565-```
6666-6767-This is necessary because SSH `AuthorizedKeysCommand` requires [really specific
6868-permissions](https://stackoverflow.com/a/27638306). Let's set that up:
6969-7070-```
7171-sudo tee /etc/ssh/sshd_config.d/authorized_keys_command.conf <<EOF
7272-Match User git
7373- AuthorizedKeysCommand /usr/local/libexec/tangled-keyfetch
7474- AuthorizedKeysCommandUser nobody
7575-EOF
7676-```
7777-7878-Next, create the `git` user:
7979-8080-```
8181-sudo adduser git
8282-```
8383-8484-Copy the `repoguard` binary to the `git` user's home directory:
99+Documentation:
85108686-```
8787-sudo cp repoguard /home/git
8888-sudo chown git:git /home/git/repoguard
8989-```
9090-9191-Now, let's set up the server. Copy the `knot` binary to
9292-`/usr/local/bin/knotserver`. Then, create `/home/git/.knot.env` with the
9393-following, updating the values as necessary. The `KNOT_SERVER_SECRET` can be
9494-obtaind from the [/knots](/knots) page on Tangled.
9595-9696-```
9797-KNOT_REPO_SCAN_PATH=/home/git
9898-KNOT_SERVER_HOSTNAME=knot.example.com
9999-APPVIEW_ENDPOINT=https://tangled.sh
100100-KNOT_SERVER_SECRET=secret
101101-KNOT_SERVER_INTERNAL_LISTEN_ADDR=127.0.0.1:5444
102102-KNOT_SERVER_LISTEN_ADDR=127.0.0.1:5555
103103-```
104104-105105-If you run a Linux distribution that uses systemd, you can use the provided
106106-service file to run the server. Copy
107107-[`knotserver.service`](https://tangled.sh/did:plc:wshs7t2adsemcrrd4snkeqli/core/blob/master/systemd/knotserver.service)
108108-to `/etc/systemd/system/`. Then, run:
109109-110110-```
111111-systemctl enable knotserver
112112-systemctl start knotserver
113113-```
114114-115115-You should now have a running knot server! You can finalize your registration by hitting the
116116-`initialize` button on the [/knots](/knots) page.
1111+* [knot hosting guide](https://tangled.sh/@tangled.sh/core/tree/master/docs/knot-hosting.md)
1212+* [contributing guide](https://tangled.sh/@tangled.sh/core/tree/master/docs/contributing.md)