# Rustdesk: Self-Hosted Teamviewer Alternative

**URL:** https://discussion.scottibyte.com/t/rustdesk-self-hosted-teamviewer-alternative/288
**Category:** Uncategorized
**Created:** [October 20, 2023, 6:49pm UTC](https://discussion.scottibyte.com/t/rustdesk-self-hosted-teamviewer-alternative/288 "2023-10-20T18:49:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![scott](https://discussion.scottibyte.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://discussion.scottibyte.com/u/scott)
#### Post date: [October 20, 2023, 6:49pm UTC](https://discussion.scottibyte.com/t/rustdesk-self-hosted-teamviewer-alternative/288/1 "2023-10-20T18:49:01Z")

</div>

Rustdesk ([https://rustdesk.com/](https://rustdesk.com/)) is the open source, self-hosted alternative to Teamviewer. Rustdesk has client programs for Windows, Linux, MacOS and Android. Rustdesk is a server based application and not a web based application which requires five application ports to be forwarded by your router.

Rustdesk does not use reverse proxy or SSL. Encryption is accomplished by private/public key pairs.

In my example, I am installing the Rustdesk server in a LXD container and then installing the Rustdesk docker application inside of it. If you have an existing Docker server, you can disregard setting up the LXD container.

If you watched my “LXD Step by Step” tutorial, we created a bridge called bridge0 and also created a “bridgeprofile” to allow our LXD container to be presented to the main LAN. I use that when creating the LXD container for Rustdesk. With that in mind, here is the command that can be used to create a LXD container for Rustdesk (I used LXD Dashboard to create the container in the video):

```auto
lxc launch ubuntu:22.04 Rustdesk --profile default --profile bridgeprofile -c limits.memory=2048MB -c limits.cpu.allowance=20% -c boot.autostart=true -c security.nesting=true

```

Connect to your container via LXD or ssh. I used LXD:

```auto
lxc shell Rustdesk

```

Update the container:

```auto
sudo apt update && sudo apt upgrade -y

```

Install docker and docker-compose:

```auto
curl -sSL https://get.docker.com | sh
sudo apt install docker-compose

```

Add my user account “scott” to the docker group:

```auto
sudo usermod -aG docker scott
newgrp docker
groups

```

Create a folder for rustdesk components as a best practice and move into it:

```auto
mkdir rustdesk
cd rustdesk

```

Create the docker-compose file:

```auto
nano docker-compose.yml

```

Insert the following into the file changing “domain.xxx” to your domain or subdomain name:

```auto
version: '3'
networks:
  rustdesk-net:
    external: false

services:
  hbbs:
    container_name: hbbs
    ports:
      - 21115:21115
      - 21116:21116
      - 21116:21116/udp
      - 21118:21118
    image: rustdesk/rustdesk-server:latest
    command: hbbs -r domain.xxx:21117
    volumes:
      - ./hbbs:/root
    networks:
      - rustdesk-net
    depends_on:
      - hbbr
    restart: unless-stopped

  hbbr:
    container_name: hbbr
    ports:
      - 21117:21117
      - 21119:21119
    image: rustdesk/rustdesk-server:latest
    command: hbbr
    volumes:
      - ./hbbr:/root
    networks:
      - rustdesk-net
    restart: unless-stopped

```

You will now want to define the port forwarding for the five required ports for your Rustdesk server.

All of the port forwards require TCP protocol and port 21116 requires both TCP and UDP protocol. All routers perform port forwarding a bit differently. Basically, you want to listen to ports 21115 - 21119 on your WAN connection of your router and forward this traffic to the same ports to the LAN address of your docker server (the LXD container in my example).

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/6adeae6566e172ba5e8ad974bb12b49127c816cf.png)

Once your port forwarding on the router is complete, deploy the rustdesk docker application:

```auto
docker compose up -d

```

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/6c8bbc38bb08a054b3dec023ef44c4b16a652b58.jpeg)

Now move into the “hbbs” folder:

```auto
cd hbbs

```

List the contents of the public key as shown in the video and copy it up to and including the “=”:

 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/be0f71cc87ad591330d77c81ac8dd6edb1949fd2.jpeg)

Your key will be different from the one listed in the example.

Launch your Rustdesk client program downloaded from [https://rustdesk.com/](https://rustdesk.com/) and go to the settings screen by selecting the hamburger menu and then choose the “network” configuration:

![image](https://discussion.scottibyte.com/uploads/default/original/1X/668b77061ebb9c9ff0d121cd889242c4a932763c.png)

Enter your domain or subdomain name into the “ID server” field. This tells the client programs the location of the rustdesk server.

Paste the public key that you copied above into the “key” field and then click “Apply”.

You need to provide the “ID Server” and the “Key” to others so that they can enter this information into their client as well so that your Rustdesk client can reach their Rustdesk client in order to be able to control their computer.

For those of you that prefer not to install your Rustdesk as a docker container, here’s an alternative installation:

```auto
wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/install.sh
chmod +x install.sh
./install.sh

```

You will now be able to use Rustdesk to remote control/assist clients, customers, students, friends or employees simply by following the procedures in the video tutorial.

Note: Thanks to @dac for the following. You can force your server to only be available to those with your public key. Simply make the changes indicated in the following image to your docker-compose.yml file.

 ![Rustdesk-secure](https://discussion.scottibyte.com/uploads/default/original/1X/0717a64325cf84ad875280284dd18343198e8b34.png)
