General overview of the steps I have taken to achieve this:
- Create an VM instance in Oracle Free Tier, running Ubuntu
- Run Rustdesk Server as a Docker container
- Allow ports that Rustdesk uses to be routed to server container by adding ingress rules
- Using a dynamic DNS host to get a stable, accessible address
- Setting up target remote clients
Most of the inspiration to do this was from this youtube video, in which I made a few changes.
– Go through setup, adding in credit card info (which they will not charge as long as you do not go past the free tier limits, which you will not with this instance running)
– Please note your cloud account name, and your username, which is your email address that you have setup.
– Create a VM instance, I recommend Ubuntu linux version 22.02 or higher.
– When you create this instance, MAKE SURE TO DOWNLOAD the private and public key for the instance. You will use this to SSH into Ubuntu. There is no password. IF YOU FORGET THIS, you will have to delete the instance and make another one since there is no way to get the private key after the VM is spun up.
– give a name to your VNIC, change your internal IP address to the VM, and a name for your subnet.
– Now it is time to SSH into the VM Ubuntu instance
– For my own sake, I am on MacOS and I used the app Shellfish, and I was able to attach the private key to the login.
– user name would be “ubuntu”, and no password. The public IP address would be listed in the instance information from Oracle Cloud. That is what you would SSH into.
– In Windows, you can use PuTTY and attach the private key
– In Terminal on MacOS (and Linux) you can attach the key within the login info in as “ssh <SSH-key> ubuntu@<oracle-cloud-ip-address>”
– Once remote into the terminal session, first thing is to run “sudo apt update && sudo apt upgrade”
– This is to run updates to the Ubuntu image before doing anything else.
– Now it is time to install Docker, Docker Compose, DuckDNS (your choice) and RustDesk.
– With DuckDNS and Rustdesk, we will use a compose.yaml file (which interacts with Docker Compose). This file will pull down the containers and start them automatically.
Docker is installed using the Docker documentation and pasting it in the terminal window. (documentation here: https://docs.docker.com/engine/install/ubuntu/)
– Using apt, copy paste these commands in the SSH terminal and wait for them to complete:
—
# Add Docker’s official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
“deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo “$VERSION_CODENAME”) stable” | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
—
Install the lastest Docker package:
—
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
—
Verify installation is succesful by running this command:
—
sudo docker run hello-world
—
– Now this is the part where we create a docker-compose file
– type in this command “sudo touch compose.yaml”
– then type “sudo nano compose.yaml”
The following is what I have pasted in my YAML file. Edit as you see fit.
– An explanation of what is going on in my YAML file
– duckdns to point a DNS to an IP address of your choice (more info here: https://www.duckdns.org/about.jsp)
– Make sure to create a free DuckDNS account, create a subdomain, and take note of the token. You would need to add the value on the compose YAML file.
– hbbs and hbbr are the Rustdesk servers that need to be run to allow self-hosting. hbbs is the service that gets the client’s IP address to know where to make the direct connection. hbbr is the service that allows relaying if direct connection cannot be established.
– hbbs would need the -r switch to point to the IP address of the instance, in this one I used the DuckDNAS subdomain which points straight back to where hbbs resides
– Watchtower is used to auto-update containers daily at 3am.
– the YAML file will pull down all the containers, install them, and run.
—
services:
duckdns:
image: lscr.io/linuxserver/duckdns:latest
container_name: duckdns
network_mode: host #optional
environment:
– PUID=1000 #optional
– PGID=1000 #optional
– TZ=America/Los_Angeles #optional
– SUBDOMAINS=example #enter your subdomain here
– TOKEN=12345 #enter your token here
– UPDATE_IP=ipv4 #optional
– LOG_FILE=false #optional
restart: unless-stopped
hbbs:
container_name: hbbs
ports:
– 21115:21115
– 21116:21116
– 21116:21116/udp
image: rustdesk/rustdesk-server:latest
command: hbbs -r #enter your full domain name here that points to your server, or the public IP of the instance -k #put your private key here.
volumes:
– ./docker/rustdesk:/root
restart: unless-stopped
hbbr:
container_name: hbbr
ports:
– 21117:21117
– 21119:21119
image: rustdesk/rustdesk-server:latest
command: hbbr
volumes:
– ./docker/rustdesk:/root
restart: unless-stopped
watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
network_mode: bridge
volumes:
– /var/run/docker.sock:/var/run/docker.sock
environment:
TZ: Americas/Los_Angeles
command: –cleanup –schedule “0 0 3 * * *” hbbr hbbs duckdns
restart: always
—
– Make sure to save the compose.yaml file when you exit.
– Now it is time to run the containers in Docker
– Start running them by typing in “sudo docker-compose up -d”
– the -d switch will allow you to run the containers in detached mode, allowing you to close your SSH session without shutting off the containers.
– You can verify at any time that the containers are running by using the command “sudo docker ps”
– Once everything is running, double check the key files that gets generated at “./docker/rustdesk”. The files should be named id_ed25519 and id_ed25519.pub
– Use the cat command “cat id_ed25519.pub” and note the output
– The output is the public key for the asymmetric encryption for Rustdesk connections.
– This key would be inputted in the “Settings-Network” section of RustDesk client, in the same area where the server ID info would be put in.
– Use the cat command “cat id_ed25519” and note the output. This is your private key. I recommend re-editing your compose YAML file with the -k switch to enforce private connections. No one else can connect to your server relay via Rustdesk without the public key.