# 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 distribution 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 < /home/git/motd ``` Note that you should add a newline at the end if setting a non-empty message since the knot won't do this for you.