...
Deploy rustdesk on ubuntu vps for self-hosted anydesk alternative
Learn how to deploy rustdesk on ubuntu vps for self-hosted anydesk alternative!

This article demonstrates how to deploy RustDesk on Ubuntu VPS for self-hosted AnyDesk alternative, enabling remote administration between remote computers.

What is RustDesk?

RustDesk is an open-source remote desktop tool—basically an alternative to AnyDesk or TeamViewer.

It lets you remotely view and control another computer over the internet for support, administration, or accessing your own machines. Its main appeal is that it can be self-hosted, meaning you can run your own RustDesk relay/rendezvous server instead of relying on a third-party remote-access provider.

Key points:

  • Remote control: connect to another PC, Mac, Linux machine, Android device, etc.
  • Open source: the main project is published publicly on GitHub.
  • Self-hostable: useful for businesses that want control over remote-access infrastructure.
  • Cross-platform: supports Windows, macOS, Linux, Android, and web/client options.
  • Common use case: IT support, remote administration, unattended access, and replacing commercial tools like TeamViewer/AnyDesk.

For an MSP, hosting provider, or internal IT team, RustDesk is attractive because it reduces dependency on proprietary remote-access platforms while giving more control over privacy, routing, and infrastructure and reducing exposure to vendor lock-in.

This guide uses RustDesk Server OSS with Docker Compose on an Ubuntu VPS. RustDesk Server OSS runs two services: hbbs, the ID/rendezvous server, and hbbr, the relay server.

RustDesk clients normally try direct peer-to-peer connection first; if NAT traversal fails, traffic falls back through the relay server.

Prerequisites: What you need

You need:

We will also recommend Docker Compose with network_mode: "host" for most Linux deployments because it is repeatable and avoids Docker port-mapping issues.

For this guide, replace rustdesk.example.com with your real DNS hostname or VPS public IP.

Launch 100% ssd ubuntu vps from $3. 19/mo!


Compare Ubuntu VPS Plans

KVM-SSD-1
KVM-SSD-8
KVM-SSD-16
KVM-SSD-32
CPU
1 Core
2 Cores
4 Cores
8 Cores
Memory
1 GB
8 GB
16 GB
32 GB
Storage
16 GB NVMe
128 GB NVMe
256 GB NVMe
512 GB NVMe
Bandwidth
1 TB
4 TB
8 TB
16 TB
Network
1 Gbps
1 Gbps
1 Gbps
1 Gbps
Delivery Time
⏱️ Instant
⏱️ Instant
⏱️ Instant
⏱️ Instant
Location
US/EU/APAC
US/EU/APAC
US/EU/APAC
US/EU/APAC
Price
$7.58*
$39.50*
$79.40*
$151.22*
KVM-SSD-1
$7.58*
CPU 1 Core
Memory 1 GB
Storage 16 GB NVMe
Bandwidth 1 TB
Network 1 Gbps
Delivery Time ⏱️ Instant
Location US/EU/APAC
KVM-SSD-8
$39.50*
CPU 2 Cores
Memory 8 GB
Storage 128 GB NVMe
Bandwidth 4 TB
Network 1 Gbps
Delivery Time ⏱️ Instant
Location US/EU/APAC
KVM-SSD-16
$79.40*
CPU 4 Cores
Memory 16 GB
Storage 256 GB NVMe
Bandwidth 8 TB
Network 1 Gbps
Delivery Time ⏱️ Instant
Location US/EU/APAC
KVM-SSD-32
$151.22*
CPU 8 Cores
Memory 32 GB
Storage 512 GB NVMe
Bandwidth 16 TB
Network 1 Gbps
Delivery Time ⏱️ Instant
Location US/EU/APAC

Deploy RustDesk on Ubuntu VPS for Self-Hosted AnyDesk Alternative

To deploy RustDesk on Ubuntu VPS for self-hosted AnyDesk alternative, follow the steps provided below:

  1. Prepare the Ubuntu VPS

    1. Point DNS to your VPS

      Create an A record:

      rustdesk.example.com  ->  YOUR_VPS_PUBLIC_IP
      

      Wait for DNS to propagate, then test from your local computer:

      ping rustdesk.example.com
      

      On the VPS, you can also check:

      dig rustdesk.example.com
      

      If you do not have DNS, you can use the VPS public IP directly in RustDesk clients.

    2. Log in to the VPS

      From your local machine:

      ssh root@YOUR_VPS_PUBLIC_IP
      

      Or, if using a sudo user:

      ssh youruser@YOUR_VPS_PUBLIC_IP
      

      Update the server:

      sudo apt update
      sudo apt upgrade -y
      

      Install basic utilities:

      sudo apt install -y ca-certificates curl gnupg lsb-release ufw
      
  2. Install Docker and Docker Compose

    1. Install Docker

      Install Docker from Ubuntu’s package repositories:

      sudo apt-get update
      sudo apt-get install ca-certificates curl gnupg
      sudo install -m 0755 -d /etc/apt/keyrings
      curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
      sudo chmod a+r /etc/apt/keyrings/docker.gpg
      echo \
        "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] 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
      sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
      

      Enable Docker at boot:

      sudo systemctl enable docker
      sudo systemctl start docker
      

      Check Docker:

      docker --version
      docker compose version
      

      Optional: allow your non-root user to run Docker:

      sudo usermod -aG docker $USER
      

      Then log out and log back in.

  3. Open the required firewall ports

    RustDesk Server OSS uses the following core ports:

    Port Protocol Service Purpose
    21115 TCP hbbs NAT type test
    21116 TCP hbbs TCP hole punching and connection service
    21116 UDP hbbs ID registration and heartbeat
    21117 TCP hbbr Relay service
    21118 TCP hbbs Web client support (optional)
    21119 TCP hbbr Web client support (optional)

    Open the ports with UFW:

    sudo ufw allow OpenSSH
    sudo ufw allow 21115/tcp
    sudo ufw allow 21116/tcp
    sudo ufw allow 21116/udp
    sudo ufw allow 21117/tcp
    sudo ufw allow 21118/tcp
    sudo ufw allow 21119/tcp
    sudo ufw enable
    

    Check status:

    sudo ufw status verbose
    

    Also make sure your VPS provider’s external firewall/security group allows the same ports.

  4. Deploy RustDesk Server

    1. Create a RustDesk server directory

      sudo mkdir -p /opt/rustdesk-server/data
      cd /opt/rustdesk-server
      

      Set ownership to your current user if needed:

      sudo chown -R $USER:$USER /opt/rustdesk-server
      
    2. Create the Docker Compose file

      Create the file:

      nano compose.yml
      

      Paste this:

      services:
        hbbs:
          container_name: hbbs
          image: rustdesk/rustdesk-server:latest
          command: hbbs
          volumes:
            - ./data:/root
          network_mode: "host"
          depends_on:
            - hbbr
          restart: unless-stopped
      
        hbbr:
          container_name: hbbr
          image: rustdesk/rustdesk-server:latest
          command: hbbr
          volumes:
            - ./data:/root
          network_mode: "host"
          restart: unless-stopped
      

      This follows RustDesk’s official Docker Compose pattern for hbbs and hbbr using a shared persistent data folder.

      Save and exit.

    3. Start RustDesk Server

      Run:

      docker compose up -d
      

      Check containers:

      docker compose ps
      

      You should see both containers running:

      hbbs
      hbbr
      

      View logs:

      docker logs hbbs
      docker logs hbbr
      
  5. Get the RustDesk server public key

    RustDesk generates the server key on the first run. The public key is normally stored in:

    /opt/rustdesk-server/data/id_ed25519.pub
    

    Show it:

    cat /opt/rustdesk-server/data/id_ed25519.pub
    

    Copy the full output.

    RustDesk clients need this public key for encrypted connections to your self-hosted server. The official client configuration docs state that the key is usually generated on the first run of hbbs and found in id_ed25519.pub in the working directory or data folder.

    Example:

    u1xzHkxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
    

    Keep this value ready for the Windows and macOS clients.

  6. Verify the server is listening

    Run:

    ss -tulpn | grep 211
    

    You should see listeners for RustDesk ports such as:

    21115
    21116
    21117
    21118
    21119
    

    You can also test from another Linux/macOS machine:

    nc -vz rustdesk.example.com 21116
    nc -vz rustdesk.example.com 21117
    

    For UDP 21116, use:

    nc -vzu rustdesk.example.com 21116
    
  7. Connect a Windows client

    1. Install RustDesk on Windows

      Download the Windows client from RustDesk’s official releases/download page. The current release page provides Windows, macOS, Linux, Android, iOS, and web builds.

      On Windows:

      1. Download the Windows .exe or .msi.
      2. Run the installer.
      3. Open RustDesk.
      4. Install the service if you want unattended access or remote access before login.
      5. Note the Windows machine’s RustDesk ID and one-time password.
    2. Configure the Windows client to use your server

      On the Windows RustDesk client:

      1. Open RustDesk.
      2. Click the menu button near your ID, usually the three dots.
      3. Go to Settings.
      4. Open Network.
      5. Click Unlock Network Settings.
      6. Enter:
      ID Server: rustdesk.example.com
      Relay Server: rustdesk.example.com
      API Server: leave blank for OSS
      Key: paste contents of id_ed25519.pub
      
      Configure rustdesk windows client to utilize rustdesk server details
      Fill the rustdesk server details inside the rustdesk client

      Most self-hosted clients need the ID Server and Key; the relay server is often optional because RustDesk can infer it, but setting it explicitly is fine. API Server is mainly for RustDesk Server Pro.

      Click Apply.

      The bottom of the client should show something like:

      Ready
      
    3. Set unattended access on Windows

      On the Windows machine:

      1. Open Settings.
      2. Go to Security.
      3. Enable or set a permanent password.
      4. Keep RustDesk running.
      5. Confirm the RustDesk service is installed if you need access when no user is logged in.

      You now have:

      Windows RustDesk ID
      Windows permanent password
      
  8. Connect a macOS client

    1.  Install RustDesk on macOS

      Download the macOS .dmg from RustDesk’s releases/download page. Choose the correct build for your Mac:

      • Apple Silicon / ARM64 for M1, M2, M3, M4 Macs.
      • x86_64 / Intel for older Intel Macs.
      • Universal if offered and you are unsure.

      Install it:

      1. Open the .dmg.
      2. Drag RustDesk into Applications.
      3. Open RustDesk from Applications.

      macOS usually requires additional permissions before RustDesk can show or control the screen. You typically need to move the app into Applications, allow it to run, and grant Accessibility, Screen Recording, and sometimes Input Monitoring permissions. Grant macOS permissions.

    2. On the Mac:
      1. Open System Settings.
      2. Go to Privacy & Security.
      3. Open Accessibility.
      4. Enable RustDesk.
      5. Go back to Privacy & Security.
      6. Open Screen Recording.
      7. Enable RustDesk.
      8. If prompted or needed, also enable Input Monitoring for RustDesk.
      9. Quit and reopen RustDesk.

      Without these permissions, you may connect to the Mac but be unable to see the screen, control the mouse, or type.

    3. Configure the macOS client to use your server

      On the Mac RustDesk client:

      1. Open RustDesk.
      2. Click the menu button near your ID.
      3. Go to Settings.
      4. Open Network.
      5. Click Unlock Network Settings.
      6. Enter:
      ID Server: rustdesk.example.com
      Relay Server: rustdesk.example.com
      API Server: leave blank for OSS
      Key: paste contents of id_ed25519.pub
      

      Click Apply.

      The client should show:

      Ready
      
    4. Set unattended access on macOS

      On the Mac:

      1. Open RustDesk.
      2. Go to Settings.
      3. Open Security.
      4. Set a permanent password.
      5. Confirm RustDesk remains running.
      6. Confirm macOS permissions are still enabled after reopening the app.

      You now have:

      macOS RustDesk ID
      macOS permanent password
      
  9. Connect Windows and macOS to each other

    You can connect in either direction.

    1. Option A: Connect from Windows to Mac

      On the Windows client:

      1. Open RustDesk.
      2. Enter the Mac’s RustDesk ID.
      3. Click Connect.
      4. Enter the Mac’s one-time password or permanent password.
      5. Accept the session on the Mac if prompted.
    2. Option B: Connect from Mac to Windows

      On the Mac client:

      1. Open RustDesk.
      2. Enter the Windows machine’s RustDesk ID.
      3. Click Connect.
      4. Enter the Windows one-time password or permanent password.
      5. Accept the session on Windows if prompted.

      Both clients must use the same:

      ID Server
      Relay Server
      Key
      
  10. Useful administration commands

    • Check RustDesk server status

      cd /opt/rustdesk-server
      docker compose ps
      
    • View logs

      docker logs hbbs --tail 100
      docker logs hbbr --tail 100
      
    • Restart RustDesk Server

      cd /opt/rustdesk-server
      docker compose restart
      
    • Stop RustDesk Server

      cd /opt/rustdesk-server
      docker compose down
      
    • Start RustDesk Server again

      cd /opt/rustdesk-server
      docker compose up -d
      
    • Update RustDesk Server

      cd /opt/rustdesk-server
      docker compose pull
      docker compose up -d
      
    • Back up the server keys

      Back up this directory:

      /opt/rustdesk-server/data
      

      Especially these files:

      id_ed25519
      id_ed25519.pub
      

      Do not lose them. If the server key changes, all clients using the old key will need to be reconfigured.

      Create a backup:

      sudo tar -czvf rustdesk-server-backup.tar.gz /opt/rustdesk-server/data
      
  11. Troubleshooting

    • Client says “Not ready” or cannot connect to server

      Check:

      docker compose ps
      docker logs hbbs --tail 100
      docker logs hbbr --tail 100
      sudo ufw status
      

      Verify that your VPS firewall allows:

      TCP 21115
      TCP 21116
      UDP 21116
      TCP 21117
      TCP 21118
      TCP 21119
      

      At minimum, RustDesk needs 21115-21117 and UDP 21116; 21118 and 21119 are for web client support.

    • Client shows key mismatch

      Re-copy the public key:

      cat /opt/rustdesk-server/data/id_ed25519.pub
      

      Paste it into each RustDesk client’s Key field.

      Make sure you did not paste extra spaces or line breaks.

    • Direct connection fails but relay works

      That is normal in some NAT/firewall environments. RustDesk tries hole punching first and falls back to hbbr relay if direct connection fails.

    • macOS connects but cannot be controlled

      Recheck macOS permissions:

      System Settings → Privacy & Security → Accessibility
      System Settings → Privacy & Security → Screen Recording
      System Settings → Privacy & Security → Input Monitoring
      

      Then quit and reopen RustDesk.

    • Windows connects but cannot control elevated/admin windows

      Install RustDesk as a service and run it with appropriate privileges. For unattended support, the service installation is usually required.

Recommended final setup

Use this client configuration on both Windows and macOS:

ID Server: rustdesk.example.com
Relay Server: rustdesk.example.com
API Server: blank
Key: contents of /opt/rustdesk-server/data/id_ed25519.pub

Use this server layout:

/opt/rustdesk-server/
├── compose.yml
└── data/
    ├── id_ed25519
    └── id_ed25519.pub

Once both clients show Ready, enter one device’s RustDesk ID into the other device and connect.

Launch 100% ssd ubuntu vps from $3. 19/mo!

Conclusion

You now know how to deploy RustDesk on Ubuntu VPS for self-hosted AnyDesk alternative and connect two remote computers allowing remote administration.

Avatar of editorial staff

Editorial Staff

Rad Web Hosting is a leading provider of web hosting, Cloud VPS, and Dedicated Servers in Dallas, TX.
lg