|
| 1 | +# Deployment guide |
| 2 | + |
| 3 | +## Requirements |
| 4 | + |
| 5 | +* `dstack` [0.20.14][dstack-0.20.14] ([0.20.16][dstack-0.20.16] for user-managed SSH public keys support) or newer |
| 6 | +* A host with access to the `dstack` server and fleets instances (HTTP and SSH egress traffic, respectively), which is accessible to `dstack` users (ingress SSH traffic) |
| 7 | + |
| 8 | +## Build |
| 9 | + |
| 10 | +There are pre-built `x86-64` Linux binaries on the GitHub [Releases][sshproxy-releases] page and Docker images on the [Docker Hub][sshproxy-docker-hub]. |
| 11 | + |
| 12 | +If you prefer to build from source, see [`scripts/build.sh`][build-script] for a build command. |
| 13 | + |
| 14 | +## Configuration |
| 15 | + |
| 16 | +`dstack-sshproxy` is configured via command-line arguments and/or environment variables. Command-line arguments have higher priority than environment variables. |
| 17 | +See `dstack-proxy --help` for a list of configuration settings and corresponding variables. |
| 18 | + |
| 19 | +There are two mandatory settings: |
| 20 | + |
| 21 | +* **Host private keys** |
| 22 | + |
| 23 | + Used for SSH server host authentication as described in [RFC 4251 Section 4.1][rfc-server-host-auth]. |
| 24 | + |
| 25 | + * CLI: `--host-key PATH` – a path to a private key file. May be used multiple times. Each file may contain multiple concatenated keys: `cat ssh_host_*_key > ssh_host_keys` |
| 26 | + * environment variable: `DSTACK_SSHPROXY_HOST_KEYS` – concatenated key files contents |
| 27 | + |
| 28 | + Keys must be in the OpenSSH format. For convenience, there is [`scripts/generate-host-keys.sh`][generate-host-keys-script] script which generates host keys of all default key types (rsa, ecdsa, and ed25519) using `ssh-keygen -A` and prints their contents to stdout. |
| 29 | + |
| 30 | + |
| 31 | +* **`dstack` server API token** |
| 32 | + |
| 33 | + Used to authenticate `dstack-sshproxy` API calls to `dstack` server |
| 34 | + |
| 35 | + * CLI: `--api-token TOKEN` |
| 36 | + * environment variable: `DSTACK_SSHPROXY_API_TOKEN` |
| 37 | + |
| 38 | + The `dstack` server URL is configured via `--api-url`/`DSTACK_SSHPROXY_API_URL` (defaults to `http://localhost:3000`, the default address of a locally running server if it's started with the `dstack server` command). |
| 39 | + |
| 40 | +To enable `dstack-sshproxy` integration on the `dstack` server side, see [Server deployment][dstack-docs-server-deployment-ssh-proxy] guide in the `dstack` docs. |
| 41 | + |
| 42 | +## Upgrade |
| 43 | + |
| 44 | +Before upgrading, check both [`dstack`][dstack-releases] and [`dstack-sshproxy`][sshproxy-releases] releases pages for any `dstack`↔`dstack-sshproxy` compatibility notes. |
| 45 | + |
| 46 | +`dstack-sshproxy` – given there is no breaking changes in the `dstack` server integration – supports rolling upgrade. Be aware that `dstack-sshproxy` does not currently support graceful connection termination, that is, on a shutdown request (`SIGTERM`/`SIGINIT` signal) it closes all downstream and upstream TCP connections immediately, **interrupting active SSH sessions**, but it's still possible to implement a graceful shutdown with an external load balancer (i.e., the deployment strategy would be to stop forwarding new connections to the old replica, drain it – wait for active connections to terminate, interrupt still active connections after a reasonable timeout, and only then stop the replica). |
| 47 | + |
| 48 | +[dstack-0.20.14]: https://github.com/dstackai/dstack/releases/tag/0.20.14 |
| 49 | +[dstack-0.20.16]: https://github.com/dstackai/dstack/releases/tag/0.20.16 |
| 50 | +[dstack-releases]: https://github.com/dstackai/dstack/releases |
| 51 | +[dstack-docs-server-deployment-ssh-proxy]: https://dstack.ai/docs/guides/server-deployment/#ssh-proxy |
| 52 | +[sshproxy-releases]: https://github.com/dstackai/sshproxy/releases |
| 53 | +[sshproxy-docker-hub]: https://hub.docker.com/r/dstackai/sshproxy/tags |
| 54 | +[build-script]: https://github.com/dstackai/sshproxy/blob/main/scripts/build.sh |
| 55 | +[generate-host-keys-script]: https://github.com/dstackai/sshproxy/blob/main/scripts/generate-host-keys.sh |
| 56 | +[rfc-server-host-auth]: https://datatracker.ietf.org/doc/html/rfc4251#section-4.1 |
0 commit comments