Skip to content

Commit 1f4fabb

Browse files
authored
Add deployment guide (#9)
1 parent 6bd455c commit 1f4fabb

File tree

2 files changed

+63
-16
lines changed

2 files changed

+63
-16
lines changed

DEPLOYMENT.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

README.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
# dstack-sshproxy
22

3-
## Usage
3+
`dstack-sshproxy` is an optional component of the [`dstack`][dstack-site] infrastructure that provides direct SSH access to workloads. It acts as a reverse SSH proxy that sits between `dstack` users (SSH clients, IDEs, etc.) and upstream SSH servers running inside `dstack` workloads.
44

5-
1. Provide private host keys via `--host-key` (a key file path, may be specified multiple times)
6-
or `$DSTACK_SSHPROXY_HOST_KEYS` (concatenated key files contents). At least one key must be provided.
7-
2. Provide dstack server API token via `--api-token` or `$DSTACK_SSHPROXY_API_TOKEN`.
5+
## Deployment
86

9-
## Options
7+
See [DEPLOYMENT.md]
108

11-
```
12-
--address string address for incoming SSH connections (default: all interfaces) [$DSTACK_SSHPROXY_ADDRESS]
13-
--port int port for incoming SSH connections (default: 30022) [$DSTACK_SSHPROXY_PORT]
14-
--host-key string [ --host-key string ] private host key path
15-
--api-url string dstack server API URL (default: "http://localhost:3000") [$DSTACK_SSHPROXY_API_URL]
16-
--api-token string dstack server API token [$DSTACK_SSHPROXY_API_TOKEN]
17-
--api-timeout int timeout of requests to dstack API, seconds (default: 10) [$DSTACK_SSHPROXY_API_TIMEOUT]
18-
--log-level string logging level (default: "info") [$DSTACK_SSHPROXY_LOG_LEVEL]
19-
```
20-
21-
## Build and run locally
9+
## Local development
2210

2311
```shell
2412
scripts/generate-host-keys.sh > .host_keys
2513
just run --host-key .host-keys --api-token <token> ...
2614
```
15+
16+
[dstack-site]: https://dstack.ai/
17+
[DEPLOYMENT.md]: https://github.com/dstackai/sshproxy/blob/main/DEPLOYMENT.md

0 commit comments

Comments
 (0)