RustDesk: Difference between revisions
| Line 27: | Line 27: | ||
hbbr: (relay) | hbbr: (relay) | ||
21117/tcp | 21117/tcp - Used for the relay server (hbbr) when direct P2P fails. | ||
21119/tcp | 21119/tcp - Used for the Web client / WebSockets. (Note: It is recommended to restrict or keep these behind a reverse proxy like Nginx rather than exposing them directly due to IP spoofing risks). | ||
hbbs: (signal) | hbbs: (signal) | ||
21116/udp | 21116/udp - Critical for ID registration, heartbeat, and peer-to-peer (P2P) hole punching. (Missing this causes a "Not ready" status). | ||
21115/tcp | 21115/tcp - Used for NAT testing and signal processing. | ||
21116/tcp | 21116/tcp - Used as a hole-punching fallback | ||
21118/tcp | 21118/tcp - Used for the Web client / WebSockets. (Note: It is recommended to restrict or keep these behind a reverse proxy like Nginx rather than exposing them directly due to IP spoofing risks). | ||
NOTE: 21118/tcp and 21119/tcp - Used for the Web client / WebSockets. (Note: It is recommended to restrict or keep these behind a reverse proxy like Nginx rather than exposing them directly due to IP spoofing risks). | |||
Note: 21114/tcp - Used for PRO API / Web Console (only) | |||
Summary: | |||
<pre> | |||
Port Protocol Purpose | |||
21114 TCP Pro API / Web console | |||
21115 TCP NAT testing | |||
21116 UDP ID registration & P2P hole punching (critical) | |||
21116 TCP Hole punching fallback | |||
21117 TCP Relay service (hbbr) | |||
21118 TCP/WSS Web client WebSocket | |||
21119 TCP/WSS Web client WebSocket | |||
</pre> | |||
=== Docker Option === | === Docker Option === | ||
Revision as of 21:50, 15 November 2026
Rust Desk
Installation
Installation :: Documentation for RustDesk https://rustdesk.com/docs/en/self-host/rustdesk-server-oss/install/
Firewall
ufw allow 22/tcp comment "SSH"
ufw allow 21116/udp comment "RustDesk" ufw allow 21115:21117/tcp comment "RustDesk" # ufw allow 21118:21119/tcp comment "RustDesk WebSockets" # ufw allow 21115:21119/tcp comment "RustDesk"
ufw allow 21115:21119/tcp comment "RustDesk"
# ufw allow 8000/tcp comment "RustDesk Web Download" # Only if you keep the web download (gohttp) # ufw allow 21114/tcp comment "RustDesk Web API" # Enterprise Only
sudo ufw enable
wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/install.sh chmod +x install.sh ./install.sh
hbbr: (relay)
21117/tcp - Used for the relay server (hbbr) when direct P2P fails. 21119/tcp - Used for the Web client / WebSockets. (Note: It is recommended to restrict or keep these behind a reverse proxy like Nginx rather than exposing them directly due to IP spoofing risks).
hbbs: (signal)
21116/udp - Critical for ID registration, heartbeat, and peer-to-peer (P2P) hole punching. (Missing this causes a "Not ready" status). 21115/tcp - Used for NAT testing and signal processing. 21116/tcp - Used as a hole-punching fallback 21118/tcp - Used for the Web client / WebSockets. (Note: It is recommended to restrict or keep these behind a reverse proxy like Nginx rather than exposing them directly due to IP spoofing risks).
NOTE: 21118/tcp and 21119/tcp - Used for the Web client / WebSockets. (Note: It is recommended to restrict or keep these behind a reverse proxy like Nginx rather than exposing them directly due to IP spoofing risks).
Note: 21114/tcp - Used for PRO API / Web Console (only)
Summary:
Port Protocol Purpose 21114 TCP Pro API / Web console 21115 TCP NAT testing 21116 UDP ID registration & P2P hole punching (critical) 21116 TCP Hole punching fallback 21117 TCP Relay service (hbbr) 21118 TCP/WSS Web client WebSocket 21119 TCP/WSS Web client WebSocket
Docker Option
Recommended
ref: https://rustdesk.com/docs/en/self-host/rustdesk-server-oss/docker/
sudo docker image pull rustdesk/rustdesk-server sudo docker run --name hbbs -v ./data:/root -td --net=host --restart unless-stopped rustdesk/rustdesk-server hbbs sudo docker run --name hbbr -v ./data:/root -td --net=host --restart unless-stopped rustdesk/rustdesk-server hbbr
bash <(wget -qO- https://get.docker.com) wget rustdesk.com/oss.yml -O compose.yml sudo docker compose up -d
techahold Service Option
https://github.com/techahold/rustdeskinstall
git clone:
git clone https://github.com/techahold/rustdeskinstall.git rustdeskinstall # or git clone git@github.com:techahold/rustdeskinstall.git rustdeskinstall cd rustdeskinstall chmod +x *.sh # Install (uses sudo, installs to /opt/rustdesk) ./install.sh # Update ./update.sh
---
/opt/rustdesk/hbbr /opt/rustdesk/hbbs
/opt/rustdesk/
db_v2.sqlite3
db_v2.sqlite3-shm
db_v2.sqlite3-wal
hbbr
hbbs
id_ed25519
id_ed25519.pub
rustdesk-utils
/var/log/rustdesk
/etc/systemd/system/multi-user.target.wants/rustdesksignal.service /etc/systemd/system/multi-user.target.wants/rustdeskrelay.service
systemctl status rustdesksignal systemctl status rustdeskrelay
---
Install:
wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/install.sh chmod +x install.sh ./install.sh
Update:
wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/install.sh chmod +x update.sh ./update.sh
---
Web config is hosted with gohttpserver.
You can get a free API with Addressbook etc via https://github.com/infiniteremote/installer
Deb Service Option
https://github.com/rustdesk/rustdesk-server/releases/latest
wget https://github.com/rustdesk/rustdesk-server/releases/download/1.1.16/rustdesk-server-hbbr_1.1.16_amd64.deb sudo dpkg -i rustdesk-server-hbbr_1.1.16_amd64.deb
sudo apt-get -f install <filename>.deb or sudo dpkg -i <filename>.deb
Web Socket Warning
WARNING
When WebSocket is enabled (ports 21118/21119 are open for the web client), hbbs/hbbr trust the X-Real-IP / X-Forwarded-For headers of incoming WebSocket connections to determine the real client IP, so that the client IP is preserved when the WebSocket traffic goes through a reverse proxy (WSS). These headers are not validated, so anyone who can reach 21118/21119 directly can spoof an arbitrary IP address with forged headers, bypassing IP-based rate limiting and blocking, and falsifying the IP addresses recorded in logs.
If you use the web client, expose the WebSocket ports only through a reverse proxy that sets X-Real-IP itself, and restrict 21118/21119 with firewall rules so that only the reverse proxy can connect to them. If you do not use the web client, keep ports 21118 and 21119 closed. <//blockquote>
Services
hbbs - RustDesk ID/Rendezvous server hbbr - RustDesk Relay server
Installation Creator
Web Client
Config Location
%AppData%\RustDesk\config\
RustDesk Docker
See https://rustdesk.com/docs/en/self-host/rustdesk-server-oss/install/
Docker Compose Example: bash <(wget -qO- https://get.docker.com) wget rustdesk.com/oss.yml -O compose.yml sudo docker compose up -d
Manual Docker Example: sudo docker image pull rustdesk/rustdesk-server sudo docker run --name hbbs -v ./data:/root -td --net=host --restart unless-stopped rustdesk/rustdesk-server hbbs sudo docker run --name hbbr -v ./data:/root -td --net=host --restart unless-stopped rustdesk/rustdesk-server hbbr
System status for RustDesk: systemctl status rustdesksignal /opt/rustdesk/hbbs systemctl status rustdeskrelay /opt/rustdesk/hbbr
systemctl stop rustdesksignal systemctl stop rustdeskrelay
Docker Guide:
Manual Installation
https://github.com/techahold/rustdeskinstall
https://github.com/rustdesk/rustdesk-server/releases/tag/1.1.16
Web Client
If you do not need web client support, the corresponding ports 21118, 21119 can be disabled.
Web Client:
When WebSocket is enabled (ports 21118/21119 are open for the web client), hbbs/hbbr trust the X-Real-IP / X-Forwarded-For headers of incoming WebSocket connections to determine the real client IP, so that the client IP is preserved when the WebSocket traffic goes through a reverse proxy (WSS).
Firewall ports
hbbs:
21114 (TCP): used for web console / (API Server), only available in Pro version.- 21115 (TCP): used for the NAT type test.
- 21116 (TCP/UDP): Please note that 21116 should be enabled both for TCP and UDP. 21116/UDP is used for the ID registration and heartbeat service. 21116/TCP is used for TCP hole punching and connection service.
- 21118 (TCP): used to support web clients.
hbbr:
- 21117 (TCP): used for the Relay services.
- 21119 (TCP): used to support web clients.
ufw allow 21115:21119/tcp comment RustDesk ufw allow 21116/udp comment RustDeskRustDesk Client URI
To connect you provide the full connect URL as part of the url, for example: 123123123@rust.example.com?key=[PUBKEY]
Deployment Scripts
See
- https://rustdesk.com/docs/en/self-host/client-deployment/
- https://rustdesk.com/blog/rustdesk-unattended-access-setup/
Windows Powershell
$ErrorActionPreference= 'silentlycontinue' # Assign the value random password to the password variable $rustdesk_pw=(-join ((65..90) + (97..122) | Get-Random -Count 12 | % {[char]$_})) # Get your config string from your Web portal and Fill Below $rustdesk_cfg="configstring" ################################## Please Do Not Edit Below This Line ######################################### # Run as administrator and stays in the current directory if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { Start-Process PowerShell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`""; Exit; } } # This function will return the latest version and download link as an object function getLatest() { $Page = Invoke-WebRequest -Uri 'https://github.com/rustdesk/rustdesk/releases/latest' -UseBasicParsing $HTML = New-Object -Com "HTMLFile" try { $HTML.IHTMLDocument2_write($Page.Content) } catch { $src = [System.Text.Encoding]::Unicode.GetBytes($Page.Content) $HTML.write($src) } # Current example link: https://github.com/rustdesk/rustdesk/releases/download/1.2.6/rustdesk-1.2.6-x86_64.exe $Downloadlink = ($HTML.Links | Where {$_.href -match '(.)+\/rustdesk\/rustdesk\/releases\/download\/\d{1}.\d{1,2}.\d{1,2}(.{0,3})\/rustdesk(.)+x86_64.exe'} | select -first 1).href # bugfix - sometimes you need to replace "about:" $Downloadlink = $Downloadlink.Replace('about:', 'https://github.com') $Version = "unknown" if ($Downloadlink -match './rustdesk/rustdesk/releases/download/(?<content>.*)/rustdesk-(.)+x86_64.exe') { $Version = $matches['content'] } if ($Version -eq "unknown" -or $Downloadlink -eq "") { Write-Output "ERROR: Version or download link not found." Exit } # Create object to return $params += @{Version = $Version} $params += @{Downloadlink = $Downloadlink} $Result = New-Object PSObject -Property $params return($Result) } $RustDeskOnGitHub = getLatest $rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version) if ($rdver -eq $RustDeskOnGitHub.Version) { Write-Output "RustDesk $rdver is the newest version." Exit } if (!(Test-Path C:\Temp)) { New-Item -ItemType Directory -Force -Path C:\Temp | Out-Null } cd C:\Temp Invoke-WebRequest $RustDeskOnGitHub.Downloadlink -Outfile "rustdesk.exe" Start-Process .\rustdesk.exe --silent-install Start-Sleep -seconds 20 $ServiceName = 'Rustdesk' $arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue if ($arrService -eq $null) { Write-Output "Installing service" cd $env:ProgramFiles\RustDesk Start-Process .\rustdesk.exe --install-service Start-Sleep -seconds 20 $arrService = Get-Service -Name $ServiceName } while ($arrService.Status -ne 'Running') { Start-Service $ServiceName Start-Sleep -seconds 5 $arrService.Refresh() } cd $env:ProgramFiles\RustDesk\ .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id .\rustdesk.exe --config $rustdesk_cfg .\rustdesk.exe --password $rustdesk_pw Write-Output "..............................................." # Show the value of the ID Variable Write-Output "RustDesk ID: $rustdesk_id" # Show the value of the Password Variable Write-Output "Password: $rustdesk_pw" Write-Output "..............................................."Windows Batch
@echo off REM Assign the value random password to the password variable setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION set alfanum=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 set rustdesk_pw= for /L %%b in (1, 1, 12) do ( set /A rnd_num=!RANDOM! %% 62 for %%c in (!rnd_num!) do ( set rustdesk_pw=!rustdesk_pw!!alfanum:~%%c,1! ) ) REM Get your config string from your Web portal and Fill Below set rustdesk_cfg="configstring" REM ############################### Please Do Not Edit Below This Line ######################################### if not exist C:\Temp\ md C:\Temp\ cd C:\Temp\ curl -L "https://github.com/rustdesk/rustdesk/releases/download/1.2.6/rustdesk-1.2.6-x86_64.exe" -o rustdesk.exe rustdesk.exe --silent-install timeout /t 20 cd "C:\Program Files\RustDesk\" rustdesk.exe --install-service timeout /t 20 for /f "delims=" %%i in ('rustdesk.exe --get-id ^| more') do set rustdesk_id=%%i rustdesk.exe --config %rustdesk_cfg% rustdesk.exe --password %rustdesk_pw% echo ............................................... REM Show the value of the ID Variable echo RustDesk ID: %rustdesk_id% REM Show the value of the Password Variable echo Password: %rustdesk_pw% echo ...............................................Windows EXE Rename
WARNING: This stopped working in version v1.4.7 due to stricter IPC security scoping that rejects processes with mismatched executable names [2]
rustdesk-host=<YOUR_SERVER_IP_OR_DOMAIN>,key=<YOUR_PUBLIC_KEY>,.exe
Linux
#!/bin/bash # Assign a random value to the password variable rustdesk_pw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1) # Get your config string from your Web portal and Fill Below rustdesk_cfg="configstring" ################################## Please Do Not Edit Below This Line ######################################### # Check if the script is being run as root if [[ $EUID -ne 0 ]]; then echo "This script must be run as root." exit 1 fi # Identify OS if [ -f /etc/os-release ]; then # freedesktop.org and systemd . /etc/os-release OS=$NAME VER=$VERSION_ID UPSTREAM_ID=${ID_LIKE,,} # Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian' if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)" fi elif type lsb_release >/dev/null 2>&1; then # linuxbase.org OS=$(lsb_release -si) VER=$(lsb_release -sr) elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command . /etc/lsb-release OS=$DISTRIB_ID VER=$DISTRIB_RELEASE elif [ -f /etc/debian_version ]; then # Older Debian, Ubuntu, etc. OS=Debian VER=$(cat /etc/debian_version) elif [ -f /etc/SuSE-release ]; then # Older SuSE etc. OS=SuSE VER=$(cat /etc/SuSE-release) elif [ -f /etc/redhat-release ]; then # Older Red Hat, CentOS, etc. OS=RedHat VER=$(cat /etc/redhat-release) else # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc. OS=$(uname -s) VER=$(uname -r) fi # Install RustDesk echo "Installing RustDesk" if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then wget https://github.com/rustdesk/rustdesk/releases/download/1.2.6/rustdesk-1.2.6-x86_64.deb apt-get install -fy ./rustdesk-1.2.6-x86_64.deb > /dev/null elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "$OS" = "Fedora Linux" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "$OS" = "Almalinux" ] || [ "$OS" = "Rocky*" ] ; then wget https://github.com/rustdesk/rustdesk/releases/download/1.2.6/rustdesk-1.2.6-0.x86_64.rpm yum localinstall ./rustdesk-1.2.6-0.x86_64.rpm -y > /dev/null else echo "Unsupported OS" # here you could ask the user for permission to try and install anyway # if they say yes, then do the install # if they say no, exit the script exit 1 fi # Run the rustdesk command with --get-id and store the output in the rustdesk_id variable rustdesk_id=$(rustdesk --get-id) # Apply new password to RustDesk rustdesk --password $rustdesk_pw &> /dev/null rustdesk --config $rustdesk_cfg systemctl restart rustdesk echo "..............................................." # Check if the rustdesk_id is not empty if [ -n "$rustdesk_id" ]; then echo "RustDesk ID: $rustdesk_id" else echo "Failed to get RustDesk ID." fi # Echo the value of the password variable echo "Password: $rustdesk_pw" echo "..............................................."Docker Service
rustdesk.com/oss.ym
Summary: bash <(wget -qO- https://get.docker.com) wget rustdesk.com/oss.yml -O compose.yml sudo docker compose up -d
Install docker bash <(wget -qO- https://get.docker.com)
mkdir /opt/rustdesk cd /opt/rustdesk
wget rustdesk.com/oss.yml -O compose.yml
docker compose up -d
cat data/id_ed25519.pub
UKi8wfaLEP3j8w0qIoq68PwE1N9Rz38RJABgwFQ4Wg4=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-stoppedNote: This standard compose.yml file uses host network mode as recommended by the RustDesk Documentation for performance and simpler firewall rules.
- https://rustdesk.com/docs/en/self-host/rustdesk-server-oss/docker/
- "For most Linux deployments, Docker Compose with network_mode: "host" is the simplest and most reliable option. It keeps the setup repeatable, makes upgrades easier, and avoids extra port-mapping complexity when host networking is available."
- https://billing.flokinet.is/index.php?rp=/knowledgebase/124/Self-hosted-RustDesk-server.html
--
If you want to do the non Host mode, and specify the ports:
services: hbbs: image: rustdesk/rustdesk-server:latest ports: - "21115:21115" - "21116:21116" - "21116:21116/udp" - "21118:21118" volumes: - ./data:/root depends_on: - hbbr restart: unless-stopped hbbr: image: rustdesk/rustdesk-server:latest ports: - "21117:21117" - "21119:21119" volumes: - ./data:/root restart: unless-stoppedkeywords