====== RustDesk Server on Devuan ======
Warning. I am still editing this on 18 Sep 2025. Do not use these instructions until I have finished editing, then tested the procedure. This notice will be removed at that time.
We use [[https://www.devuan.org/|Devuan]] as an alternative to Debian as Devuan allows us to choose the init system instead of forcing the use of SystemD. With its many faults, we still choose SysVInit for our init system, and Devuan allows that.
An excellent Rust Server install script is available at [[https://github.com/techahold/rustdeskinstall/blob/master/install.sh|GitHub built by techahold]]. This script has a lot of extra features, but unfortunately, it assumes SystemD, and will fail halfway through as it is attempting to set up the SystemD service. The same is true of the .deb package which is available from RustDesk.
This article describes how to set up the Rust Server on Devuan, and may be helpful for other systems also.
===== Set up user =====
Rust Server does not require any special privileges, so creating a separate user account instead of running as root greatly enhances security. The following few lines assume we will install rust in /opt/rustdesk, and the log files will be stored in /var/log/rustdesk/*, and a system user named rust
#! /usr/bin/env sh
useradd --shell /usr/sbin/nologin --system --user-group --home-dir /opt/rustdesk rust
mkdir /opt/rustdesk
mkdir /var/log/rustdesk
chown rust:rust /opt/rustdesk
chown rust:rust /var/log/rustdesk
===== Download Server =====
Open a web browser to https://github.com/rustdesk/rustdesk-server/releases, locate the entry for //rustdesk-server-linux-amd64.zip//. Right click on it and select "Copy Link".
cd /tmp
wget ###Paste the URL from above here###
unzip rustdesk-server-linux-amd64.zip
mv /tmp/amd64/* /opt/rustdesk
chown rust:rust /opt/rustdesk/*
This will create three binary files in /opt/rustdesk
* hbbr - The relay server. If a direct P2P connection can not be made, this will be used to relay traffic between clients.
* hbbs - this is the "signal" server. Your clients will ping this to notify they exist, and will use it to set up a connection between clients.
* rustdesk-utils - a utility program that can generate/verify key pairs, and also run some basic tests on your service
===== Run for first time =====
The first time you run the signal server (hbbs), it will note that the key pair used for authentication does not exist and generate them. These keys are stored in the files:
* id_ed25519 - the private key
* id_ed25519.pub - the public key required by any client wanting to connect to this server
**Note**: The check is made in the current working directory, so you **must** run hbbs from within it's home directory (/opt/rustdesk)
A way that gives you more control is to run the rustdesk-utils, generate the key, then run hbbs.
cd /opt/rustdesk
sudo -u rust ./rustdesk-utils genkeypair
# verify they exist
ls -ablph id_ed25519*
# make them owned by the rust user
chown rust:rust id_ed25519*
sudo -u rust ./hbbs
# watch for errors, press ^c to leave.
echo Your key for the clients is
cat id_ed25519.pub
echo To find this again at a later date, just run the command cat id_ed25519.pub
===== Set automatic run =====
Everything up to this point will work on all Unix systems, and we have done nothing that techahold's install script will do faster, and more reliably. However, for the Unix systems which do not use SysV, we need a SysV init script. Actually two; one for hbbr and one for hbbs.
Copy the following two files to /etc/init.d (Devuan), or wherever your init scripts are stored. By the way, I built these starting with the template at [[https://github.com/fhd/init-script-template|fhd's Github]].
#!/bin/sh
### BEGIN INIT INFO
# Provides: hbbs
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Rust Signaling Server
# Description: This provides the definition of the signaling server for rust
### END INIT INFO
dir="/opt/rust"
cmd="hbbs"
user="rust"
name=`basename $0`
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
get_pid() {
cat "$pid_file"
}
is_running() {
[ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1
}
case "$1" in
start)
if is_running; then
echo "Already started"
else
echo "Starting $name"
cd "$dir"
if [ -z "$user" ]; then
sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
else
sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
fi
echo $! > "$pid_file"
if ! is_running; then
echo "Unable to start, see $stdout_log and $stderr_log"
exit 1
fi
fi
;;
stop)
if is_running; then
echo -n "Stopping $name.."
kill `get_pid`
for i in 1 2 3 4 5 6 7 8 9 10
# for i in `seq 10`
do
if ! is_running; then
break
fi
echo -n "."
sleep 1
done
echo
if is_running; then
echo "Not stopped; may still be shutting down or shutdown may have failed"
exit 1
else
echo "Stopped"
if [ -f "$pid_file" ]; then
rm "$pid_file"
fi
fi
else
echo "Not running"
fi
;;
restart)
$0 stop
if is_running; then
echo "Unable to stop, will not attempt to start"
exit 1
fi
$0 start
;;
status)
if is_running; then
echo "Running"
else
echo "Stopped"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
#!/bin/sh
### BEGIN INIT INFO
# Provides: hbbs
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Rust Relay Server
# Description: This provides the definition of the relay server for rust
### END INIT INFO
dir="/opt/rust"
cmd="hbbr"
user="rust"
name=`basename $0`
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
get_pid() {
cat "$pid_file"
}
is_running() {
[ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1
}
case "$1" in
start)
if is_running; then
echo "Already started"
else
echo "Starting $name"
cd "$dir"
if [ -z "$user" ]; then
sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
else
sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
fi
echo $! > "$pid_file"
if ! is_running; then
echo "Unable to start, see $stdout_log and $stderr_log"
exit 1
fi
fi
;;
stop)
if is_running; then
echo -n "Stopping $name.."
kill `get_pid`
for i in 1 2 3 4 5 6 7 8 9 10
# for i in `seq 10`
do
if ! is_running; then
break
fi
echo -n "."
sleep 1
done
echo
if is_running; then
echo "Not stopped; may still be shutting down or shutdown may have failed"
exit 1
else
echo "Stopped"
if [ -f "$pid_file" ]; then
rm "$pid_file"
fi
fi
else
echo "Not running"
fi
;;
restart)
$0 stop
if is_running; then
echo "Unable to stop, will not attempt to start"
exit 1
fi
$0 start
;;
status)
if is_running; then
echo "Running"
else
echo "Stopped"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
Now (we're almost done), run the following commands to start the both servers up.
chmod 755 /etc/init.d/hbbr
chmod 755 /etc/init.d/hbbs
# test hbbs
/etc/init.d/hbbs start
# test hbbr
/etc/init.d/hbbr start
# if both worked correctly, run the following command to automatically start at boot
update-rc.d hbbs defaults
update-rc.d hbbr defaults
If you made it through the last step with no errors, you should now be able to access the server from one of the clients.
===== Optional Steps =====
The script that techahold wrote will ask permission, then automatically install a lightweight web server and create customized installers for Windows and Linux. I'm not going into that here, but it is pretty straightforward. Another github user, dinger1986, has install scripts for [[https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1|Microsoft Windows]] and many flavors of [[https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh|Linux]] (not Devuan, unfortunately).
Basically, you can download those scripts and run the following commands on them. Then, make them available to your users who can run them on their computer and have RustDesk Client installed on their computer, already set up for your server.
Download and edit the following file. Change your.url.or.ip to the URL or IP of your new server, and change contents_of_public_key_file_on_your_server to the contents of /opt/rustdesk/id_ed25519.pub. When done, you will have two files, //WindowsAgentAIOInstall.ps1//, which can be run with Windows Power Shell, and //linuxclientinstall.sh// which can be run from the command line on a Linux machine.
#!/usr/bin/env sh
WANIP=your.url.or.ip
KEY=contents_of_public_key_file_on_your_server
string="{\"host\":\"${wanip}\",\"relay\":\"${wanip}\",\"key\":\"${key}\",\"api\":\"https://${wanip}\"}"
string64=$(echo -n "$string" | base64 -w 0 | tr -d '=')
string64rev=$(echo -n "$string64" | rev)
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1
sudo sed -i "s|secure-string|${string64rev}|g" WindowsAgentAIOInstall.ps1
# Create linux install script
wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh
sudo sed -i "s|secure-string|${string64rev}|g" linuxclientinstall.sh
===== Links =====
* [[https://github.com/fhd/init-script-template|Template for creating SysV init scripts]]
* [[https://github.com/techahold/rustdeskinstall/blob/master/install.sh|Excellent install script for open source RustDesk Server on Linux which uses SystemD]]
* [[https://rustdesk.com/docs/en/self-host/rustdesk-server-oss/install/|Documentation from RustDesk for installing the Open Source server]]
* [[https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/|Installer Scripts for RustDesk Client]]
* [[https://rustdesk.com/docs/en/self-host/client-deployment/|Several customized installer scripts for RustDesk Client]]