vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Serve the front door from vole serve
c5f2c5d49be1d35a0a54fd70029ac9311647194e · Keenan Nemetz · 16d ago · parent e075258f
Serve the front door from vole serve The forced command had nothing to talk to. This gives `vole serve` the local listener, the token it consumes, and the host key a lease now carries. `ssh_listen` decides what serves SSH and is the only switch: "tcp" is the built-in listener on `ssh_addr` (the default, and unchanged), "socket" is the system sshd in front, "none" serves nothing. The socket path stays in `ssh_socket`, which #304 already added, so no value lives in two places. In socket mode `ssh_addr` only names the host and port clone URLs carry, which validation now enforces by refusing another port: the point of the mode is a clone URL with no port, and a leftover 2222 would silently break every link. The local listener speaks the framed protocol from `internal/sshwire` and turns it back into the Session the built-in listener produces, so `handleLocal` calls the same `exec` with the account and key from the token row and the same ACL, credential-scoping, and refusal code runs. A test proves it: every kind of handler — whoami, roster, both git pack services, the admin API, the run queue, release channels, a refused verb, and a job credential that may do less than its account — is driven over both transports and compared byte for byte, status included. A front-door instance has no signer, so `New` no longer creates a private host key it would never present: it reads sshd's public key from `ssh_public_host_key_file` into the same field a lease carries. A missing or unreadable file fails startup rather than handing a job a key that cannot verify its host, and `Serve` refuses outright when there is no host key. The transport's own details: a write larger than a frame is split rather than refused, stdout and stderr share one socket under one lock, expired tokens are swept every thirty seconds and once at startup so a mode switch leaves nothing behind, and the socket is created 0660 with a stale file replaced only after checking that nothing answers on it. `ssh_user` replaces the hardcoded `git` in generated clone URLs, which is what lets a host with another forge's `git` account keep both. Packaging and the sshd drop-in are #306; the documentation and migration are #307.
forge/config/config.go +32−4
| @@ -11,6 +11,15 @@ import ( | |||
| 11 | 11 | "github.com/BurntSushi/toml" | |
| 12 | 12 | ) | |
| 13 | 13 | ||
| 14 | // The ways an instance may serve SSH. SSHListenTCP is the built-in listener; | ||
| 15 | // SSHListenSocket is the system sshd in front, with this process reached over a | ||
| 16 | // local socket; SSHListenNone serves no SSH surface at all. | ||
| 17 | const ( | ||
| 18 | SSHListenTCP = "tcp" | ||
| 19 | SSHListenSocket = "socket" | ||
| 20 | SSHListenNone = "none" | ||
| 21 | ) | ||
| 22 | |||
| 14 | 23 | type Config struct { | |
| 15 | 24 | DataDir string `toml:"data_dir"` | |
| 16 | 25 | // HTTPAddr serves the web UI and anonymous git clone. When HTTPSAddr is | |
| @@ -44,6 +53,19 @@ type Config struct { | |||
| 44 | 53 | // SSH handshake, so a client that opens a socket and says nothing cannot hold a | |
| 45 | 54 | // connection slot indefinitely. Zero means 20. | |
| 46 | 55 | SSHHandshakeTimeoutSeconds int `toml:"ssh_handshake_timeout_seconds"` | |
| 56 | // SSHListen is how the SSH surface is served: "tcp" (this process accepts | ||
| 57 | // SSH connections, the default), "socket" (the system sshd authenticates and | ||
| 58 | // the forced command reaches this process over ssh_socket), or "none". | ||
| 59 | SSHListen string `toml:"ssh_listen"` | ||
| 60 | // SSHUser is the account name in generated clone URLs and, in the front | ||
| 61 | // door's mode, the account sshd runs the forced command as. Changing it is how | ||
| 62 | // a host that already has a `git` account for another forge keeps both. | ||
| 63 | SSHUser string `toml:"ssh_user"` | ||
| 64 | // SSHPublicHostKeyFile is sshd's public host key. In the front door's mode a | ||
| 65 | // lease carries this key, because the client now verifies sshd rather than | ||
| 66 | // data/ssh_host_ed25519_key. Empty in direct mode, where this process is the | ||
| 67 | // SSH server and its own key is the one a job sees. | ||
| 68 | SSHPublicHostKeyFile string `toml:"ssh_public_host_key_file"` | ||
| 47 | 69 | // SSHSocket is the Unix socket `vole serve` listens on for the front door's | |
| 48 | 70 | // forced command, and the address `vole ssh-exec` connects to. It sits outside | |
| 49 | 71 | // data_dir on purpose: the `git` account must reach the socket without | |
| @@ -180,6 +202,8 @@ func defaults() *Config { | |||
| 180 | 202 | SSHMaxConnections: 64, | |
| 181 | 203 | SSHMaxGitProcesses: 16, | |
| 182 | 204 | SSHHandshakeTimeoutSeconds: 20, | |
| 205 | SSHListen: SSHListenTCP, | ||
| 206 | SSHUser: "git", | ||
| 183 | 207 | SSHSocket: "/run/vole/ssh.sock", | |
| 184 | 208 | MaxBlobBytes: 100 << 20, // 100 MiB per blob | |
| 185 | 209 | ReceiveMaxBytes: 1 << 30, // 1 GiB per push | |
| @@ -386,11 +410,15 @@ http_addr = "127.0.0.1:8080" | |||
| 386 | 410 | # The only write githttp. Identity is the SSH key presented at handshake. | |
| 387 | 411 | ssh_addr = "127.0.0.1:2222" | |
| 388 | 412 | ||
| 389 | # Where the front door's forced command reaches the service when the system sshd | ||
| 390 | # is doing the authentication. It belongs outside data_dir: the account sshd runs | ||
| 391 | # must reach the socket without reaching the repositories, the roster, or the | ||
| 392 | # host key. | ||
| 413 | # Let the system sshd be the front door: it authenticates the key and runs a | ||
| 414 | # forced command that reaches this process over ssh_socket. "tcp" (the default) | ||
| 415 | # keeps this process's own SSH listener; "none" serves no SSH at all. With the | ||
| 416 | # front door on, ssh_addr names the address clone URLs should carry (sshd on 22) | ||
| 417 | # and ssh_public_host_key_file is sshd's public key, which a CI job verifies. | ||
| 418 | # ssh_listen = "socket" | ||
| 419 | # ssh_user = "git" | ||
| 393 | 420 | # ssh_socket = "/run/vole/ssh.sock" | |
| 421 | # ssh_public_host_key_file = "/etc/ssh/ssh_host_ed25519_key.pub" | ||
| 394 | 422 | ||
| 395 | 423 | # Where a browser reads this instance. Set it to the canonical https URL to | |
| 396 | 424 | # enable passkey login; WebAuthn is bound to this origin. The CLI also uses it to | |