···3434git clone https://tangled.sh/@tangled.sh/core
3535```
36363737-Then, build our binaries (you need to have Go installed):
3838-* `knotserver`: the main server program
3939-* `keyfetch`: utility to fetch ssh pubkeys
4040-* `repoguard`: enforces repository access control
3737+Then, build the `knot` CLI. This is the knot administration and operation tool.
3838+For the purpose of this guide, we're only concerned with these subcommands:
3939+4040+* `knot server`: the main knot server process, typically run as a
4141+supervised service
4242+* `knot guard`: handles role-based access control for git over SSH
4343+(you'll never have to run this yourself)
4444+* `knot keys`: fetches SSH keys associated with your knot; we'll use
4545+this to generate the SSH `AuthorizedKeysCommand`
41464247```
4348cd core
4449export CGO_ENABLED=1
4545-go build -o knot ./cmd/knotserver
4646-go build -o keyfetch ./cmd/keyfetch
4747-go build -o repoguard ./cmd/repoguard
5050+go build -o knot ./cmd/knot
4851```
49525050-Next, move the `keyfetch` binary to a location owned by `root` --
5151-`/usr/local/libexec/tangled-keyfetch` is a good choice:
5353+Next, move the `knot` binary to a location owned by `root` --
5454+`/usr/local/bin/knot` is a good choice:
52555356```
5454-sudo mv keyfetch /usr/local/libexec/tangled-keyfetch
5555-sudo chown root:root /usr/local/libexec/tangled-keyfetch
5656-sudo chmod 755 /usr/local/libexec/tangled-keyfetch
5757+sudo mv knot /usr/local/bin/knot
5758```
58595959-This is necessary because SSH `AuthorizedKeysCommand` requires [really specific
6060-permissions](https://stackoverflow.com/a/27638306). Let's set that up:
6060+This is necessary because SSH `AuthorizedKeysCommand` requires [really
6161+specific permissions](https://stackoverflow.com/a/27638306). The
6262+`AuthorizedKeysCommand` specifies a command that is run by `sshd` to
6363+retrieve a user's public SSH keys dynamically for authentication. Let's
6464+set that up.
61656266```
6367sudo tee /etc/ssh/sshd_config.d/authorized_keys_command.conf <<EOF
6468Match User git
6565- AuthorizedKeysCommand /usr/local/libexec/tangled-keyfetch
6969+ AuthorizedKeysCommand /usr/local/bin/knot keys -o authorized-keys
6670 AuthorizedKeysCommandUser nobody
6771EOF
6872```
69737070-Next, create the `git` user:
7474+Next, create the `git` user. We'll use the `git` user's home directory
7575+to store repositories:
71767277```
7378sudo adduser git
7479```
75807676-Copy the `repoguard` binary to the `git` user's home directory:
7777-7878-```
7979-sudo cp repoguard /home/git
8080-sudo chown git:git /home/git/repoguard
8181-```
8282-8383-Now, let's set up the server. Copy the `knot` binary to
8484-`/usr/local/bin/knotserver`. Then, create `/home/git/.knot.env` with the
8585-following, updating the values as necessary. The `KNOT_SERVER_SECRET` can be
8686-obtaind from the [/knots](/knots) page on Tangled.
8181+Create `/home/git/.knot.env` with the following, updating the values as
8282+necessary. The `KNOT_SERVER_SECRET` can be obtaind from the
8383+[/knots](/knots) page on Tangled.
87848885```
8986KNOT_REPO_SCAN_PATH=/home/git
···96939794If you run a Linux distribution that uses systemd, you can use the provided
9895service file to run the server. Copy
9999-[`knotserver.service`](https://tangled.sh/did:plc:wshs7t2adsemcrrd4snkeqli/core/blob/master/systemd/knotserver.service)
9696+[`knotserver.service`](/systemd/knotserver.service)
10097to `/etc/systemd/system/`. Then, run:
1019810299```
···161158KNOT_REPO_SCAN_PATH=/home/git/repositories
162159```
163160164164-In your SSH config (e.g. `/etc/ssh/sshd_config.d/authorized_keys_command.conf`),
165165-update the `AuthorizedKeysCommand` line to use the new folder. For example:
161161+Similarly, update your `sshd` `AuthorizedKeysCommand` to use the updated
162162+repository path:
166163167164```
165165+sudo tee /etc/ssh/sshd_config.d/authorized_keys_command.conf <<EOF
168166Match User git
169169- AuthorizedKeysCommand /usr/local/libexec/tangled-keyfetch -git-dir /home/git/repositories
167167+ AuthorizedKeysCommand /usr/local/bin/knot keys -o authorized-keys -git-dir /home/git/repositories
170168 AuthorizedKeysCommandUser nobody
171171-```
172172-173173-Make sure to restart your SSH server!
174174-175175-#### git
176176-177177-The keyfetch executable takes multiple arguments to change certain paths. You
178178-can view a full list by running `/usr/local/libexec/tangled-keyfetch -h`.
179179-180180-As an example, if you wanted to change the path to the repoguard executable,
181181-you would edit your SSH config (e.g. `/etc/ssh/sshd_config.d/authorized_keys_command.conf`)
182182-and update the `AuthorizedKeysCommand` line:
183183-184184-```
185185-Match User git
186186- AuthorizedKeysCommand /usr/local/libexec/tangled-keyfetch -repoguard-path /path/to/repoguard
187187- AuthorizedKeysCommandUser nobody
169169+EOF
188170```
189171190172Make sure to restart your SSH server!