You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
6.9 KiB
Markdown

2 years ago
# Rustdesk in docker
###### guide-by-example
![logo](https://i.imgur.com/ImsIffW.png)
# Purpose & Overview
2 years ago
Remote desktop access.
2 years ago
* [Official site](https://rustdesk.com/)
* [Github](https://github.com/rustdesk/rustdesk)
2 years ago
* [DockerHub for S6](https://hub.docker.com/r/rustdesk/rustdesk-server-s6)
2 years ago
2 years ago
Rustdesk is a new opensource replacement for TeamViewer or Anydesk.<br>
The major aspects are that it does NAT punching,
and lets you host all the infrastructure for it to function.<br>
2 years ago
Written in rust(gasp), with Dart and Flutter framework for client side.</br>
2 years ago
The idea is:
2 years ago
2 years ago
* run a rustdesk server reachable online
* install clients on machines you want to connect from / to
* the clients application keeps a regular heartbeat communication
with the server, this punches hole in the NAT and so allows connection
initialized from the outside without doing port forwarding
2 years ago
---
2 years ago
![interface-pic](https://i.imgur.com/ekA7Hms.png)
2 years ago
# Files and directory structure
```
/home/
└── ~/
└── docker/
└── rustdesk/
2 years ago
├── 🗁 rustdesk_data/
├── 🗋 .env
└── 🗋 docker-compose.yml
2 years ago
```
2 years ago
* `rustdesk_data/` - persistent data, contains sqlite database and the keys
2 years ago
* `.env` - a file containing environment variables for docker compose
* `docker-compose.yml` - a docker compose file, telling docker how to run the containers
2 years ago
You only need to provide the two files.</br>
The directory is created by docker compose on the first run.
2 years ago
# docker-compose
2 years ago
Using an edited version of [S6-overlay based compose.](https://github.com/rustdesk/rustdesk-server#s6-overlay-based-images)<br>
2 years ago
It's a simpler, single container approach. The complexity of hbbs/hbbr hidden.
2 years ago
It also has health check implemented.
2 years ago
2 years ago
There is no network section since no working http traffic yet. So just mapped
ports on to docker host do their thing.
2 years ago
`docker-compose.yml`
```yml
services:
rustdesk:
2 years ago
image: rustdesk/rustdesk-server-s6:1.1.7-1
2 years ago
container_name: rustdesk
hostname: rustdesk
restart: unless-stopped
env_file: .env
ports:
2 years ago
- "21116:21116"
- "21115:21115"
- "21116:21116/udp"
- "21117:21117"
- "21118:21118"
- "21119:21119"
2 years ago
volumes:
2 years ago
- ./rustdesk_data:/data
2 years ago
```
`.env`
```bash
# GENERAL
TZ=Europe/Bratislava
# RUSTDESK
RELAY=rust.example.com:21117
2 years ago
ENCRYPTED_ONLY=1
# KEY_PRIV=<put here content of ./rustdesk_data/id_ed25519>
# KEY_PUB=<put here content of ./rustdesk_data/id_ed25519.pub>
2 years ago
```
2 years ago
In the `.env` file encryption only is enabled, so that only clients that have
correct public key will be allowed access to the rustdesk server.<br>
The keys are generated on the first run of the compose and can be found in
`rustdesk_data` directory. Once generated they should be added to the `.env` file
for easier migration. The public key will need to be distributed with
the clients apps install.
2 years ago
# Port forwarding
2 years ago
as can be seen in the compose
* **21115 - 21119** TCP need to be forwarded to docker host<br>
* **21116** is TCP and UDP
21115 is used for the NAT type test,
21116/UDP is used for the ID registration and heartbeat service,
21116/TCP is used for TCP hole punching and connection service,
21117 is used for the Relay services,
and 21118 and 21119 are used to support web clients.
[source](https://rustdesk.com/docs/en/self-host/install/)
2 years ago
2 years ago
---
2 years ago
2 years ago
![interface-pic](https://i.imgur.com/CK6pRyq.png)
2 years ago
# The installation on clients
2 years ago
2 years ago
* download and install the client apps from [the official site](https://rustdesk.com/)
2 years ago
* three dots near ID > ID/Relay Server
* ID Server: rust.example.com
* Key: *\<content of id_ed25519.pub\>*
* the green dot at the bottom should be green saying "ready"
2 years ago
* done
2 years ago
![settings-pic](https://i.imgur.com/lX6egMH.png)
2 years ago
2 years ago
**On windows** one [can](https://rustdesk.com/docs/en/self-host/install/#put-config-in-rustdeskexe-file-name-windows-only)
deploy client with **pre-set settings** by renaming the installation file to:
`rustdesk-host=<host-ip-or-name>,key=<public-key-string>.exe`
2 years ago
example: `rustdesk-host=rust.example.com,key=3AVva64bn1ea2vsDuOuQH3i8+2M=.exe`
2 years ago
If by chance the public key contains symbols not usable in windows filenames,
down the container, delete the files `id_ed25519` and `id_ed25519.pub`,
2 years ago
up the container and try with the new keys.
# Extra info
* You really really **really want to be using domain and not your public IP**
when instaling clients and setting ID server. That domain can be changed
to different IP any time you want. IP not.
* You wont get much response on github if questions is around selfhosting.
[#763](https://github.com/rustdesk/rustdesk/discussions/763),
maybe trying [their discord.](https://discord.com/invite/nDceKgxnkV)
* `tcpdump -n udp port 21116` to **see heartbeat** udp traffic, seems machines
report-in every \~13 seconds.
* on **windows** machine a **service** named `rustdesk` is enabled.
Disable it if want machine accessible only on demand,
when someone first runs rustdesk.<br>
In powershell - `Set-Service rustdesk -StartupType Disabled`
2 years ago
# Trouble shooting
2 years ago
#### If just one machine is having issues.
2 years ago
2 years ago
uninstall, plus delete:
2 years ago
* `C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk`
* `%AppData%\RustDesk`
2 years ago
2 years ago
Restart. Reinstall.<br>
Do not use the installer you used berfore, **download** from the site latest.
---
#### Error - Failed to connect to relay server
* I had wrongly set env variable `RELAY`
* generally issue might be with port 21117 if green dot is green
---
#### Investigate port forwarding
Install netcat and tcpdump on the docker host.
* docker compose down rustdesk container so that ports are free to use
* start small netcat server listening on whichever port we test<br>
`sudo nc -u -vv -l -p 21116`
* on a machine somewhere else in the world, not on the same network, try
`nc -u <public-ip> 21116`
If you start writing something, it should appear on the other machine, confirming
that port forwarding works.<br>
The -u flag for netcat command is for udp port testing, without it its for tcp.
2 years ago
2 years ago
Also useful command can be `tcpdump -n udp port 21116`<br>
When port forwarding works, one should see heartbeat chatter,
as machines with installed rustdesk are announcing themselves every \~13 seconds.
2 years ago
2 years ago
# Manual image update:
2 years ago
- `docker-compose pull`</br>
- `docker-compose up -d`</br>
- `docker image prune`
# Backup and restore
#### Backup
Using [borg](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/borg_backup)
that makes daily snapshot of the entire directory.
#### Restore
* down the bookstack containers `docker-compose down`</br>
* delete the entire bookstack directory</br>
* from the backup copy back the bookstack directory</br>
* start the containers `docker-compose up -d`