Skip to content

Commit 128bbff

Browse files
authored
Document SSH console and RCON password secrets file (#3843)
1 parent 82aafd5 commit 128bbff

File tree

3 files changed

+120
-10
lines changed

3 files changed

+120
-10
lines changed

docs/configuration/server-properties.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,46 @@ By default an existing `server-icon.png` file will not be replaced, that can be
238238

239239
### RCON
240240

241-
RCON is **enabled by default** to allow for graceful shut down the server and coordination of save state during backups. RCON can be disabled by setting `ENABLE_RCON` to "false".
241+
RCON is **enabled by default** to allow for graceful shut down of the server and coordination of save state during backups. RCON can be disabled by setting `ENABLE_RCON` to "false".
242242

243243
!!! warning
244244

245245
Disabling RCON will remove and limit some features, such as interactive and color console support.
246246

247-
The default password is randomly generated on each startup; however, a specific one can be set with `RCON_PASSWORD`.
247+
#### RCON Password
248248

249-
**DO NOT MAP THE RCON PORT EXTERNALLY** unless you are aware of all the consequences and have set a **secure password** with `RCON_PASSWORD`.
249+
The default password is randomly generated on each startup. However, you can specify a password using one of the following environment variables:
250+
251+
* Set `RCON_PASSWORD` to your desired password.
252+
* Set `RCON_PASSWORD_FILE` to the path of a file containing the password.
253+
254+
Using `RCON_PASSWORD_FILE` is the recommended method for managing sensitive data, as it allows full support for [Docker Secrets](https://docs.docker.com/compose/how-tos/use-secrets/).
255+
256+
??? example
257+
```yaml title="compose.yaml"
258+
services:
259+
mc:
260+
image: itzg/minecraft-server:latest
261+
pull_policy: daily
262+
tty: true
263+
stdin_open: true
264+
ports:
265+
- "25565:25565"
266+
environment:
267+
EULA: "TRUE"
268+
RCON_PASSWORD_FILE: /run/secrets/rcon_pass # Points to the path where the secret is mounted
269+
volumes:
270+
# attach the relative directory 'data' to the container's /data path
271+
- ./data:/data
272+
secrets:
273+
- rcon_pass
274+
275+
secrets:
276+
rcon_pass:
277+
file: ./rcon_password # local file containing the password
278+
```
279+
!!! warning
280+
**BE CAUTIOUS OF MAPPING THE RCON PORT EXTERNALLY** unless you are aware of all the consequences and have set a **secure password**.
250281

251282
!!! info
252283

@@ -444,4 +475,4 @@ When using `docker run` from a bash shell, the entries must be quoted with the `
444475
| STATUS_HEARTBEAT_INTERVAL | [status-heartbeat-interval](https://minecraft.wiki/w/Server.properties#status-heartbeat-interval) |
445476
| SYNC_CHUNK_WRITES | [sync-chunk-writes](https://minecraft.wiki/w/Server.properties#sync-chunk-writes) |
446477
| USE_NATIVE_TRANSPORT | [use-native-transport](https://minecraft.wiki/w/Server.properties#use-native-transport) |
447-
| VIEW_DISTANCE | [view-distance](https://minecraft.wiki/w/Server.properties#view-distance) |
478+
| VIEW_DISTANCE | [view-distance](https://minecraft.wiki/w/Server.properties#view-distance) |

docs/sending-commands/ssh.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Over SSH
3+
---
4+
5+
The container can host an SSH console. It is enabled by setting `ENABLE_SSH` to `true`.
6+
The SSH server only supports password based authentication. The password is the same as the RCON password.
7+
8+
!!! question
9+
See [the RCON password](../configuration/server-properties.md/#rcon-password) section under configuration/server-properties for more information on how to set an RCON password.
10+
11+
The SSH server runs on port `2222` inside the container.
12+
13+
??? tip "Tip: Exposing the SSH port"
14+
15+
!!! warning "Security Implications"
16+
By default, publishing ports in Docker binds them to all network interfaces (`0.0.0.0`), making the SSH console accessible to any device that can reach your host machine.
17+
18+
Since the SSH console grants **full administrative access** to your server, it is critical to use a strong [RCON password](../configuration/server-properties.md/#rcon-password).
19+
20+
If you wish to restrict access to the local machine only, refer to the [Docker documentation](https://docs.docker.com/engine/network/port-publishing/#publishing-ports) on binding to specific IP addresses (e.g., `127.0.0.1:2222:2222`).
21+
22+
If SSH access is only intended for inter-container connections, consider **NOT** forwarding the port to the host machine, and putting the containers in a shared [Docker network](https://docs.docker.com/engine/network/#user-defined-networks).
23+
24+
```yaml title="compose.yaml"
25+
services:
26+
mc:
27+
ports:
28+
- '25565:25565'
29+
- '2222:2222'
30+
```
31+
32+
## Connecting
33+
34+
Connecting should be as simple as running
35+
```bash
36+
ssh [email protected] -p 2222
37+
```
38+
and typing in the RCON password.
39+
40+
## Environment variables
41+
42+
| Environment Variable | Usage | Default |
43+
| -------------------- | ------------------------- | ------- |
44+
| `ENABLE_SSH` | Enable remote SSH console | `false` |
45+
46+
47+
## Example
48+
49+
```yaml title="compose.yaml"
50+
services:
51+
mc:
52+
image: itzg/minecraft-server:latest
53+
pull_policy: daily
54+
tty: true
55+
stdin_open: true
56+
ports:
57+
- "25565:25565"
58+
- "2222:2222"
59+
environment:
60+
EULA: "TRUE"
61+
ENABLE_SSH: true
62+
RCON_PASSWORD_FILE: /run/secrets/rcon_pass
63+
volumes:
64+
# attach the relative directory 'data' to the container's /data path
65+
- ./data:/data
66+
67+
secrets:
68+
rcon_pass:
69+
file: ./rcon_password
70+
```

docs/sending-commands/websocket.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: With websocket
2+
title: With WebSocket
33
---
44

5-
With `WEBSOCKET_CONSOLE` set to `true`, logs can be streamed, and commands sent, over a websocket connection.
5+
With `WEBSOCKET_CONSOLE` set to `true`, logs can be streamed, and commands sent, over a WebSocket connection.
66
The API is available on `/console`.
77

88
## Password
@@ -21,7 +21,16 @@ The listen address and port can be set with `WEBSOCKET_ADDRESS` (defaults to `0.
2121
## Log history
2222
When a connection is established, the last 50 (by default, configurable with `WEBSOCKET_LOG_BUFFER_SIZE`) log lines are sent with a `logHistory` type message.
2323

24-
??? tip "Tip: Remember to forward the websocket port on the host"
24+
??? tip "Tip: Remember to forward the WebSocket port on the host"
25+
26+
!!! warning "Security Implications"
27+
By default, publishing ports in Docker binds them to all network interfaces (`0.0.0.0`), making the WebSocket console accessible to any device that can reach your host machine.
28+
29+
Since the WebSocket console grants **full administrative access** to your server, it is critical to use a strong [WebSocket password](#password) or [RCON password](../configuration/server-properties.md/#rcon-password).
30+
31+
If you wish to restrict access to the local machine only, refer to the [Docker documentation](https://docs.docker.com/engine/network/port-publishing/#publishing-ports) on binding to specific IP addresses (e.g., `127.0.0.1:80:80`).
32+
33+
If WebSocket access is only intended for inter-container connections, consider **NOT** forwarding the port to the host machine, and putting the containers in a shared [Docker network](https://docs.docker.com/engine/network/#user-defined-networks).
2534

2635
```yaml title="compose.yaml"
2736
services:
@@ -34,12 +43,12 @@ When a connection is established, the last 50 (by default, configurable with `WE
3443
## Environment variables
3544
| Environment Variable | Usage | Default |
3645
| ---------------------------------- | ---------------------------------------------------------- | ------------ |
37-
| `WEBSOCKET_CONSOLE` | Allow remote shell over websocket | `false` |
38-
| `WEBSOCKET_ADDRESS` | Bind address for websocket server | `0.0.0.0:80` |
46+
| `WEBSOCKET_CONSOLE` | Allow remote shell over WebSocket | `false` |
47+
| `WEBSOCKET_ADDRESS` | Bind address for WebSocket server | `0.0.0.0:80` |
3948
| `WEBSOCKET_DISABLE_ORIGIN_CHECK` | Disable checking if origin is trusted | `false` |
4049
| `WEBSOCKET_ALLOWED_ORIGINS` | Comma-separated list of trusted origins | ` ` |
4150
| `WEBSOCKET_PASSWORD` | Password will be the same as RCON_PASSWORD if unset | ` ` |
42-
| `WEBSOCKET_DISABLE_AUTHENTICATION` | Disable websocket authentication | `false` |
51+
| `WEBSOCKET_DISABLE_AUTHENTICATION` | Disable WebSocket authentication | `false` |
4352
| `WEBSOCKET_LOG_BUFFER_SIZE` | Number of log lines to save and send to connecting clients | `50` |
4453

4554
## API Schema

0 commit comments

Comments
 (0)