RustDesk is a self-hosted alternative to AnyDesk and TeamViewer

RustDesk is a free and open-source remote desktop application similar to TeamViewer or AnyDesk. It allows you to manage both the server and client software, providing complete control over your remote access setup.

To get started, you’ll need a Linux server with minimal resources (1 CPU, 1 GB RAM, 10 GB disk).

Server Installation

  1. Prepare your server: Choose a VPS provider and set up a domain or subdomain pointing to your server’s IP address.

  2. Connect and update: SSH into your server as root and update Debian.

    1
    2
    
    ssh root@youripaddress
    apt update && apt upgrade -y
    
  3. Install packages: Install necessary packages.

    1
    
    apt install -y software-properties-common dirmngr file-roller unzip wget gnupg git curl vim tmux ufw sudo
    
  4. Create a user: Create a new user ‘rustdesk’ with sudo privileges.

    1
    2
    
    adduser rustdesk
    adduser rustdesk sudo
    
  5. Configure firewall: Allow necessary ports through your firewall.

    1
    2
    3
    4
    5
    6
    
    ufw allow 22/tcp
    ufw allow 21115:21119/tcp
    ufw allow 8000/tcp
    ufw allow 21116/udp
    ufw enable
    systemctl start ufw
    
  6. Copy SSH key: Copy your root SSH key to the new user’s directory and adjust ownership.

    1
    2
    3
    
    mkdir -p /home/rustdesk/.ssh
    cp ./.ssh/* /home/rustdesk/.ssh/
    chown -R rustdesk:rustdesk /home/rustdesk/.ssh/
    
  7. Reconnect and install Docker: Reboot your server, reconnect as the new ‘rustdesk’ user, and run the Docker installation script.

    1
    2
    3
    4
    
    ssh rustdesk@youripaddress
    wget -O install-docker.sh  https://gitlab.com/bmcgonag/docker_installs/-/raw/main/install_docker_nproxyman.sh
    chmod +x install-docker.sh
    ./install-docker.sh
    
  8. Create RustDesk directory: Create a directory for RustDesk within the docker directory.

    1
    
    cd docker && mkdir rustdesk && cd rustdesk
    
  9. Create docker-compose.yml: Create a ‘docker-compose.yml’ file and paste the provided configuration.

    1
    
    nano docker-compose.yml
    

    (Paste the provided ‘docker-compose.yml’ content here)

  10. Start the server: Start the RustDesk server using docker-compose.

    1
    
    docker-compose up -d
    
  11. Verify the logs: Check if the server is running correctly by viewing the logs.

    1
    
    docker-compose logs -f
    

Client Setup

  1. Download and install: Download the RustDesk client from RustDesk.com and install it on your desired devices.

  2. Connect to your server: After launching the client, click the three-dot icon next to your ID, select “ID/Relay Server,” and enter your server’s domain or subdomain along with the port number.

    [Image of the three-dot menu and ID/Relay Server popup]

  3. Verify connection: You should see a “Ready” message in the RustDesk client window, indicating a successful connection to your server.

Security

By default, RustDesk runs unencrypted, which is suitable for private networks. However, for online use, enable encryption:

  1. Locate the key: On your server, navigate to the ‘hbbs’ directory within the RustDesk folder and open the ‘id_ed25519.pub’ file.

    1
    2
    
    cd ~/docker/rustdesk/hbbs
    nano id_ed25519.pub
    
  2. Copy and distribute: Copy the key from this file and paste it into the ‘Key’ field on all your RustDesk clients. This ensures encrypted communication between clients connected to your server.

Restricting Server Access

To prevent unauthorized access, add your secret key to the server configuration:

  1. Edit docker-compose.yml: Open the ‘docker-compose.yml’ file.

    1
    2
    
    cd..
    nano docker-compose.yml
    
  2. Append your key: Add your secret key to the ‘command’ section of both ‘hbbs’ and ‘hbbr’ services.

    [Image of the modified docker-compose.yml]

  3. Restart containers: Restart your Docker containers for the changes to take effect.

    1
    
    docker-compose up -d
    

    This configuration forces both server and client to use the secret key for connection, effectively preventing access from unauthorized clients.

This setup ensures your RustDesk connections are encrypted and your server is only accessible by clients with the secret key. For more information, refer to the official RustDesk documentation.

Licensed under CC BY-NC-SA 4.0
Last updated on Feb 14, 2023 21:43 +0100