Table of Contents

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 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 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

setupRustDeskServer
#! /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

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:

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
</bash>
 
===== 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]].
 
<code bash hbbs>
#!/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
hbbr
#!/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.