RustDesk Setup
Today we're going to install and configure RustDesk, an opensource alternative to TeamViewer that lets you connect remotely to an instance. This involves installing and configuring a RustDesk server that will act as a connection relay between our client and our local workstation.
Initial Setup
Please setup your firewall on your server prior to running the script. Make sure you have got access via ssh or otherwise setup prior setting up the firewall, command for UFW is:
ufw allow 22
ufw allow 21115:21119/tcp
ufw allow 8000/tcp
ufw allow 21116/udp
sudo ufw reload
Please remember to forward all the following ports, respecting the protocol used from your instance to the web
21115/tcp
21116/tcp
21116/udp
21117/tcp
21118/tcp
21119/tcp
Setup directory tree
sudo mkdir /opt/rustdesk
sudo mkdir -p /var/cache/apt/archives
sudo chown -R _apt: /var/cache/apt/archives
Server Setup
To install rustdesk, we'll use a script that will fully automate its deployment. You'll need a domain name or a static public IP address to which the rustdesk instance can be reached.
#Download the installation script
wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/install.sh
#Make it executable
chmod +x install.sh
#Run the script
./install.sh
When running the script, you will be asked the following questions: First, select the option corresponding to your needs, depending on whether you want to reach your instance by its domain name or by its public IP address. Secondly, choose whether you want to install the goHTTP service to provide a web server that we can join to download the installation scripts for our clients, preconfigured to match our RustDesk server configurations.
root@rrd:~# ./install.sh
Installing prerequisites
Get:1 http://security.debian.org bookworm-security InRelease [48.0 kB]
Hit:2 http://deb.debian.org/debian bookworm InRelease
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
Get:4 http://security.debian.org bookworm-security/main amd64 Packages [86.2 kB]
Get:5 http://security.debian.org bookworm-security/main Translation-en [48.8 kB]
Get:6 http://security.debian.org bookworm-security/contrib amd64 Packages [644 B]
Get:7 http://security.debian.org bookworm-security/contrib Translation-en [372 B]
Fetched 236 kB in 2s (120 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
wget is already the newest version (1.21.3-1+b2).
tar is already the newest version (1.34+dfsg-1.2).
The following additional packages will be installed:
libcurl4
Suggested packages:
zip
The following NEW packages will be installed:
curl dnsutils libcurl4 unzip
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 1130 kB of archives.
After this operation, 2021 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 dnsutils all 1:9.18.19-1~deb12u1 [259 kB]
Get:2 http://security.debian.org bookworm-security/main amd64 libcurl4 amd64 7.88.1-10+deb12u4 [390 kB]
Get:3 http://security.debian.org bookworm-security/main amd64 curl amd64 7.88.1-10+deb12u4 [315 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 unzip amd64 6.0-28 [166 kB]
Fetched 1130 kB in 0s (13.8 MB/s)
Selecting previously unselected package libcurl4:amd64.
(Reading database ... 21375 files and directories currently installed.)
Preparing to unpack .../libcurl4_7.88.1-10+deb12u4_amd64.deb ...
Unpacking libcurl4:amd64 (7.88.1-10+deb12u4) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.88.1-10+deb12u4_amd64.deb ...
Unpacking curl (7.88.1-10+deb12u4) ...
Selecting previously unselected package dnsutils.
Preparing to unpack .../dnsutils_1%3a9.18.19-1~deb12u1_all.deb ...
Unpacking dnsutils (1:9.18.19-1~deb12u1) ...
Selecting previously unselected package unzip.
Preparing to unpack .../unzip_6.0-28_amd64.deb ...
Unpacking unzip (6.0-28) ...
Setting up unzip (6.0-28) ...
Setting up dnsutils (1:9.18.19-1~deb12u1) ...
Setting up libcurl4:amd64 (7.88.1-10+deb12u4) ...
Setting up curl (7.88.1-10+deb12u4) ...
Processing triggers for libc-bin (2.36-9+deb12u3) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for mailcap (3.70+nmu1) ...
**1) IP
2) DNS/Domain
Choose your preferred option, IP or DNS/Domain:2
Enter your preferred domain/dns address : mydomain.co**
Creating /opt/rustdesk
Installing Rustdesk Server
--2023-10-19 12:32:34-- https://github.com/rustdesk/rustdesk-server/releases/download/1.1.8-2/rustdesk-server-linux-amd64.zip
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/299354666/afce0804-6c91-4e20-8b1c-1c49a4d12eaf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential;=AKIAIWNJYAX4CSVEH53A%2F20231019%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date;=20231019T123234Z&X-Amz-Expires;=300&X-Amz-Signature;=1020540b41d6f5a074ef0d59509c879c851b032f06859c2af6f051498ccd54fa&X-Amz-SignedHeaders;=host&actor;_id=0&key;_id=0&repo;_id=299354666&response-content-disposition;=attachment%3B%20filename%3Drustdesk-server-linux-amd64.zip&response-content-type;=application%2Foctet-stream [following]
--2023-10-19 12:32:34-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/299354666/afce0804-6c91-4e20-8b1c-1c49a4d12eaf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential;=AKIAIWNJYAX4CSVEH53A%2F20231019%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date;=20231019T123234Z&X-Amz-Expires;=300&X-Amz-Signature;=1020540b41d6f5a074ef0d59509c879c851b032f06859c2af6f051498ccd54fa&X-Amz-SignedHeaders;=host&actor;_id=0&key;_id=0&repo;_id=299354666&response-content-disposition;=attachment%3B%20filename%3Drustdesk-server-linux-amd64.zip&response-content-type;=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8528063 (8.1M) [application/octet-stream]
Saving to: 'rustdesk-server-linux-amd64.zip'
rustdesk-server-linux-amd64.z 100%[=================================================>] 8.13M 18.6MB/s in 0.4s
2023-10-19 12:32:34 (18.6 MB/s) - 'rustdesk-server-linux-amd64.zip' saved [8528063/8528063]
Archive: rustdesk-server-linux-amd64.zip
inflating: amd64/hbbr
inflating: amd64/hbbs
inflating: amd64/rustdesk-utils
Creating /var/log/rustdesk
Created symlink /etc/systemd/system/multi-user.target.wants/rustdesksignal.service -> /etc/systemd/system/rustdesksignal.service.
Created symlink /etc/systemd/system/multi-user.target.wants/rustdeskrelay.service -> /etc/systemd/system/rustdeskrelay.service.
Rustdesk Relay not ready yet...
Tidying up install
**1) Yes
2) No
Please choose if you want to download configs and install HTTP server:1**
--2023-10-19 12:32:45-- https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.111.133, 185.199.110.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3337 (3.3K) [text/plain]
Saving to: 'WindowsAgentAIOInstall.ps1'
WindowsAgentAIOInstall.ps1 100%[=================================================>] 3.26K --.-KB/s in 0s
2023-10-19 12:32:45 (47.0 MB/s) - 'WindowsAgentAIOInstall.ps1' saved [3337/3337]
--2023-10-19 12:32:45-- https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4682 (4.6K) [text/plain]
Saving to: 'linuxclientinstall.sh'
linuxclientinstall.sh 100%[=================================================>] 4.57K --.-KB/s in 0s
2023-10-19 12:32:45 (53.3 MB/s) - 'linuxclientinstall.sh' saved [4682/4682]
Creating /opt/gohttp
Installing Go HTTP Server
--2023-10-19 12:32:46-- https://github.com/codeskyblue/gohttpserver/releases/download/1.1.4/gohttpserver_1.1.4_linux_amd64.tar.gz
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/63852314/3b4f8927-1e46-46b6-873c-6407b36d0f92?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential;=AKIAIWNJYAX4CSVEH53A%2F20231019%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date;=20231019T123246Z&X-Amz-Expires;=300&X-Amz-Signature;=7da01a41539e3e1e3307687dcaa5769d13eca4d42134a21b5a0ac6d021122a7b&X-Amz-SignedHeaders;=host&actor;_id=0&key;_id=0&repo;_id=63852314&response-content-disposition;=attachment%3B%20filename%3Dgohttpserver_1.1.4_linux_amd64.tar.gz&response-content-type;=application%2Foctet-stream [following]
--2023-10-19 12:32:46-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/63852314/3b4f8927-1e46-46b6-873c-6407b36d0f92?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential;=AKIAIWNJYAX4CSVEH53A%2F20231019%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date;=20231019T123246Z&X-Amz-Expires;=300&X-Amz-Signature;=7da01a41539e3e1e3307687dcaa5769d13eca4d42134a21b5a0ac6d021122a7b&X-Amz-SignedHeaders;=host&actor;_id=0&key;_id=0&repo;_id=63852314&response-content-disposition;=attachment%3B%20filename%3Dgohttpserver_1.1.4_linux_amd64.tar.gz&response-content-type;=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.110.133, 185.199.108.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4864160 (4.6M) [application/octet-stream]
Saving to: 'gohttpserver_1.1.4_linux_amd64.tar.gz'
gohttpserver_1.1.4_linux_amd6 100%[=================================================>] 4.64M 20.2MB/s in 0.2s
2023-10-19 12:32:46 (20.2 MB/s) - 'gohttpserver_1.1.4_linux_amd64.tar.gz' saved [4864160/4864160]
Creating /var/log/gohttp
Tidying up Go HTTP Server Install
Created symlink /etc/systemd/system/multi-user.target.wants/gohttpserver.service -> /etc/systemd/system/gohttpserver.service.
**Your IP/DNS Address is mydomain.co
Your public key is mypubkey
Install Rustdesk on your machines and change your public key and IP/DNS name to the above
You can access your install scripts for clients by going to http://mydomain.co:8000
Username is admin and password is myPasswd**
If you "lose" the public key given at the end of script execution, you will be able to find it in the tree below
root@rrd:/opt/rustdesk# ls -la
total 27692
drwxr-xr-x 2 root root 4096 Oct 19 08:37 .
drwxr-xr-x 4 root root 4096 Oct 19 08:37 ..
-rw-r--r-- 1 root root 4096 Oct 19 08:37 db_v2.sqlite3
-rw-r--r-- 1 root root 32768 Oct 19 08:52 db_v2.sqlite3-shm
-rw-r--r-- 1 root root 70072 Oct 19 08:52 db_v2.sqlite3-wal
-rwxr-xr-x 1 root root 9171176 Jul 25 07:48 hbbr
-rwxr-xr-x 1 root root 14314024 Jul 25 07:48 hbbs
-rw-r--r-- 1 root root 88 Oct 19 08:37 id_ed25519
**-rw-r--r-- 1 root root 44 Oct 19 08:37 id_ed25519.pub** <-- cat this
-rwxr-xr-x 1 root root 4734912 Jul 25 07:48 rustdesk-utils
Manual Client configuration
Click on the 3 dots to go in the rustdesk client settings
After that you can go to the network section, and put your rustdesk domain in the ID server and Relay Server section. Put the previous public key in the key section and the url of your api in the API server box.
Once you have configured your client to use your rustDesk server by filling in the various information, click on apply to save the configuration and test the connection on your client.
Once the client has been configured, simply enter its id to see it appear on the rust desk interface, then double-click on it to launch the connection to the client.
Enter your password
Well done, we are now connected to our remote host through our RustDesk instance.
Auto deploy client with generated scripts
If you choose to setup an HTTP server during the installation, you can join it in your web browser to get an automatic client already configured to match your RustDesk server settings.
After dl the scripts juste make it executables and run it on your client Careful the initial setup set a basic auth password for access to the gui. If you loose or you want to change them you can recover or modify it in the rustdesk service file
#Edit the service file
vim /etc/systemd/system/gohttpserver.service
Here you can see your Basic Auth credentials
[Unit]
Description=Go HTTP Server
[Service]
Type=simple
LimitNOFILE=1000000
**ExecStart=/opt/gohttp/gohttpserver -r ./public --port 8000 --auth-type http --auth-http admin:myPasswd**
WorkingDirectory=/opt/gohttp/
User=root
Group=root
Restart=always
StandardOutput=append:/var/log/gohttp/gohttpserver.log
StandardError=append:/var/log/gohttp/gohttpserver.error
# Restart service after 10 seconds if node service crashes
RestartSec=10
[Install]
WantedBy=multi-user.target
Upgrade your Server
Run the following commands:
#Download update script
wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/update.sh
#Make it executables
chmod +x update.sh
#Run it
./update.sh
Nihilist
8AUYjhQeG3D5aodJDtqG499N5jXXM71gYKD8LgSsFB9BUV1o
7muLv3DXHoydRTK4SZaaUBq4EAUqpZHLrX2VZLH71Jrd9k8 Donate XMR to Nihilist: