doc.rustdesk.com/content/self-host/client-deployment/_index.en.md

361 lines
11 KiB
Markdown
Raw Normal View History

2023-08-21 21:46:01 +02:00
---
title: Client Deployment
2023-08-29 05:42:52 +02:00
weight: 400
pre: "<b>2.4. </b>"
2023-08-21 21:46:01 +02:00
---
2023-10-21 21:51:13 +02:00
You can deploy using a number of methods, some are covered in [Client Configuration](https://rustdesk.com/docs/en/self-host/client-configuration/).
2023-08-21 21:46:01 +02:00
2023-08-31 21:58:07 +02:00
Alternatively you can use mass deployment scripts with your RMM, Intune, etc. The ID and password are output by the script. You should collect this or split it into different scripts to collect the ID and password.
2023-08-21 21:46:01 +02:00
2023-08-31 21:58:07 +02:00
The permanent password can be changed from random to one you prefer using by changing the content inside `()` after `rustdesk_pw` to your preferred password for PowerShell and the corresponding line for any other platform.
2023-08-24 17:56:01 +02:00
2023-08-27 20:43:15 +02:00
### PowerShell
2023-08-21 21:46:01 +02:00
```ps
$ErrorActionPreference= 'silentlycontinue'
2023-08-24 18:11:12 +02:00
# Assign the value random password to the password variable
2023-08-31 21:58:07 +02:00
$rustdesk_pw=(-join ((65..90) + (97..122) | Get-Random -Count 12 | % {[char]$_}))
2023-08-24 17:56:01 +02:00
2023-08-27 20:43:15 +02:00
# Get your config string from your Web portal and Fill Below
2023-09-28 12:08:18 +02:00
$rustdesk_cfg="configstring"
2023-08-24 17:56:01 +02:00
2023-08-27 20:43:15 +02:00
################################### Please Do Not Edit Below This Line #########################################
2023-08-24 17:56:01 +02:00
2023-08-27 20:43:15 +02:00
# Run as administrator and stays in the current directory
2023-10-01 13:52:30 +02:00
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)
{
2023-08-24 18:11:12 +02:00
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)
}
2024-02-09 21:38:15 +01:00
# Current example link: https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-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
2024-02-09 21:38:15 +01:00
# bugfix - sometimes you need to replace "about:"
$Downloadlink = $Downloadlink.Replace('about:', 'https://github.com')
2024-02-09 21:38:15 +01:00
$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
2024-02-09 21:38:15 +01:00
$Result = New-Object PSObject -Property
@{
Version = $Version
Downloadlink = $Downloadlink
}
return($Result)
}
$RustDeskOnGitHub = getLatest
2023-08-24 17:56:01 +02:00
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version)
2023-08-21 21:46:01 +02:00
if ($rdver -eq $RustDeskOnGitHub.Version)
2023-08-21 21:46:01 +02:00
{
2024-02-09 21:38:15 +01:00
Write-Output "RustDesk $rdver is the newest version."
2023-09-13 23:22:27 +02:00
Exit
2023-08-21 21:46:01 +02:00
}
2023-10-10 21:44:27 +02:00
if (!(Test-Path C:\Temp))
2023-09-13 23:22:27 +02:00
{
New-Item -ItemType Directory -Force -Path C:\Temp > null
2023-08-21 21:46:01 +02:00
}
2023-08-31 21:58:07 +02:00
cd C:\Temp
2023-08-21 21:46:01 +02:00
Invoke-WebRequest $RustDeskOnGitHub.Downloadlink -Outfile "rustdesk.exe"
Start-Process .\rustdesk.exe --silent-install
Start-Sleep -seconds 20
2023-08-21 21:46:01 +02:00
$ServiceName = 'Rustdesk'
$arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
if ($arrService -eq $null)
{
2023-10-01 13:52:30 +02:00
Write-Output "Installing service"
cd $env:ProgramFiles\RustDesk
Start-Process .\rustdesk.exe --install-service
2023-10-01 13:52:30 +02:00
Start-Sleep -seconds 20
2023-08-21 21:46:01 +02:00
}
while ($arrService.Status -ne 'Running')
{
Start-Service $ServiceName
Start-Sleep -seconds 5
$arrService.Refresh()
}
2023-08-24 14:40:15 +02:00
2023-08-24 15:32:22 +02:00
cd $env:ProgramFiles\RustDesk\
2023-10-10 21:44:27 +02:00
.\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id
2023-08-24 15:32:22 +02:00
2023-10-10 21:44:27 +02:00
.\rustdesk.exe --config $rustdesk_cfg
2023-08-24 18:11:12 +02:00
2023-10-10 21:44:27 +02:00
.\rustdesk.exe --password $rustdesk_pw
2023-08-24 15:32:22 +02:00
2023-08-24 18:11:12 +02:00
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 "..............................................."
2023-08-21 21:46:01 +02:00
```
2023-08-28 23:02:51 +02:00
### Windows batch/cmd
```bat
2023-09-09 12:36:12 +02:00
@echo off
2023-08-28 23:02:51 +02:00
REM Assign the value random password to the password variable
2023-09-06 21:32:12 +02:00
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
set alfanum=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
2023-08-28 23:02:51 +02:00
set rustdesk_pw=
2023-10-23 14:53:14 +02:00
for /L %%b in (1, 1, 12) do (
2023-10-10 21:44:27 +02:00
set /A rnd_num=!RANDOM! %% 62
2023-10-23 14:53:14 +02:00
for %%c in (!rnd_num!) do (
set rustdesk_pw=!rustdesk_pw!!alfanum:~%%c,1!
)
2023-09-06 21:32:12 +02:00
)
2023-08-28 23:02:51 +02:00
REM Get your config string from your Web portal and Fill Below
2023-08-31 21:58:07 +02:00
set rustdesk_cfg="configstring"
2023-08-28 23:02:51 +02:00
REM ############################### Please Do Not Edit Below This Line #########################################
2023-08-31 21:58:07 +02:00
if not exist C:\Temp\ md C:\Temp\
cd C:\Temp\
2023-08-28 23:02:51 +02:00
2023-10-23 22:02:40 +02:00
curl -L "https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.exe" -o rustdesk.exe
2023-08-28 23:02:51 +02:00
rustdesk.exe --silent-install
2023-09-09 12:36:12 +02:00
timeout /t 20
2023-08-28 23:02:51 +02:00
2023-08-31 21:58:07 +02:00
cd "C:\Program Files\RustDesk\"
2023-10-06 17:56:53 +02:00
rustdesk.exe --install-service
2023-10-06 17:45:02 +02:00
timeout /t 20
2023-10-10 21:44:27 +02:00
for /f "delims=" %%i in ('rustdesk.exe --get-id ^| more') do set rustdesk_id=%%i
2023-08-28 23:02:51 +02:00
2023-10-10 21:44:27 +02:00
rustdesk.exe --config %rustdesk_cfg%
2023-08-28 23:02:51 +02:00
2023-10-10 21:44:27 +02:00
rustdesk.exe --password %rustdesk_pw%
2023-08-28 23:02:51 +02:00
2023-09-09 12:36:12 +02:00
echo ...............................................
2023-08-28 23:02:51 +02:00
REM Show the value of the ID Variable
2023-09-09 12:36:12 +02:00
echo RustDesk ID: %rustdesk_id%
2023-08-28 23:02:51 +02:00
REM Show the value of the Password Variable
2023-09-09 12:36:12 +02:00
echo Password: %rustdesk_pw%
echo ...............................................
2023-08-28 23:02:51 +02:00
```
2023-08-24 18:11:12 +02:00
2023-08-27 20:43:15 +02:00
### macOS Bash
2023-08-21 21:46:01 +02:00
```sh
#!/bin/bash
2023-08-24 14:40:15 +02:00
# Assign the value random password to the password variable
2023-08-24 18:11:12 +02:00
rustdesk_pw=$(openssl rand -hex 4)
2023-08-21 21:46:01 +02:00
2023-08-27 20:43:15 +02:00
# Get your config string from your Web portal and Fill Below
2023-08-31 21:58:07 +02:00
rustdesk_cfg="configstring"
2023-08-21 21:46:01 +02:00
2023-08-27 20:43:15 +02:00
################################### Please Do Not Edit Below This Line #########################################
2023-08-21 21:46:01 +02:00
# Check if the script is being run as root
if [[ $EUID -ne 0 ]]; then
2023-10-01 13:52:30 +02:00
echo "This script must be run as root."
exit 1
2023-08-21 21:46:01 +02:00
fi
# Specify the path to the rustdesk.dmg file
2023-10-23 22:02:40 +02:00
dmg_file="/tmp/rustdesk-1.2.3-x86_64.dmg"
2023-08-21 21:46:01 +02:00
# Specify the mount point for the DMG (temporary directory)
mount_point="/Volumes/RustDesk"
# Download the rustdesk.dmg file
echo "Downloading RustDesk Now"
2023-08-24 14:40:15 +02:00
if [[ $(arch) == 'arm64' ]]; then
2023-10-23 22:02:40 +02:00
curl -L https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-aarch64.dmg --output "$dmg_file"
2023-08-24 14:40:15 +02:00
else
2023-10-23 22:02:40 +02:00
curl -L https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.dmg --output "$dmg_file"
2023-08-24 14:40:15 +02:00
fi
2023-08-21 21:46:01 +02:00
# Mount the DMG file to the specified mount point
hdiutil attach "$dmg_file" -mountpoint "$mount_point" &> /dev/null
# Check if the mounting was successful
if [ $? -eq 0 ]; then
2023-10-01 13:52:30 +02:00
# Move the contents of the mounted DMG to the /Applications folder
cp -R "$mount_point/RustDesk.app" "/Applications/" &> /dev/null
# Unmount the DMG file
hdiutil detach "$mount_point" &> /dev/null
2023-08-21 21:46:01 +02:00
else
2023-10-01 13:52:30 +02:00
echo "Failed to mount the RustDesk DMG. Installation aborted."
exit 1
2023-08-21 21:46:01 +02:00
fi
# Run the rustdesk command with --get-id and store the output in the rustdesk_id variable
cd /Applications/RustDesk.app/Contents/MacOS/
rustdesk_id=$(./RustDesk --get-id)
# Apply new password to RustDesk
./RustDesk --server &
2023-08-24 18:11:12 +02:00
/Applications/RustDesk.app/Contents/MacOS/RustDesk --password $rustdesk_pw &> /dev/null
2023-08-21 21:46:01 +02:00
2023-08-24 18:11:12 +02:00
/Applications/RustDesk.app/Contents/MacOS/RustDesk --config $rustdesk_cfg
2023-08-21 21:46:01 +02:00
# Kill all processes named RustDesk
rdpid=$(pgrep RustDesk)
kill $rdpid &> /dev/null
echo "..............................................."
# Check if the rustdesk_id is not empty
if [ -n "$rustdesk_id" ]; then
2023-10-01 13:52:30 +02:00
echo "RustDesk ID: $rustdesk_id"
2023-08-21 21:46:01 +02:00
else
2023-10-01 13:52:30 +02:00
echo "Failed to get RustDesk ID."
2023-08-21 21:46:01 +02:00
fi
# Echo the value of the password variable
2023-08-24 18:11:12 +02:00
echo "Password: $rustdesk_pw"
2023-08-21 21:46:01 +02:00
echo "..............................................."
echo "Please complete install on GUI, launching RustDesk now."
open -n /Applications/RustDesk.app
```
### Linux
```sh
#!/bin/bash
2023-08-24 15:03:22 +02:00
# Assign a random value to the password variable
2023-08-24 18:11:12 +02:00
rustdesk_pw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
2023-08-24 15:03:22 +02:00
2023-08-27 20:43:15 +02:00
# Get your config string from your Web portal and Fill Below
2023-08-31 21:58:07 +02:00
rustdesk_cfg="configstring"
2023-08-21 21:46:01 +02:00
2023-08-27 20:43:15 +02:00
################################### Please Do Not Edit Below This Line #########################################
2023-08-21 21:46:01 +02:00
# Check if the script is being run as root
if [[ $EUID -ne 0 ]]; then
2023-10-01 13:52:30 +02:00
echo "This script must be run as root."
exit 1
2023-08-21 21:46:01 +02:00
fi
2023-08-27 20:43:15 +02:00
# Identify OS
2023-08-21 21:46:01 +02:00
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
2023-08-27 20:43:15 +02:00
# Older Debian, Ubuntu, etc.
2023-08-21 21:46:01 +02:00
OS=Debian
VER=$(cat /etc/debian_version)
2023-08-27 20:43:15 +02:00
elif [ -f /etc/SuSE-release ]; then
# Older SuSE etc.
2023-08-21 21:46:01 +02:00
OS=SuSE
2023-08-27 20:43:15 +02:00
VER=$(cat /etc/SuSE-release)
2023-08-21 21:46:01 +02:00
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
2023-08-27 20:43:15 +02:00
# Install RustDesk
2023-08-21 21:46:01 +02:00
2023-08-27 20:43:15 +02:00
echo "Installing RustDesk"
2023-09-13 23:22:27 +02:00
if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then
2023-10-23 22:02:40 +02:00
wget https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.deb
apt-get install -fy ./rustdesk-1.2.3-x86_64.deb > null
2023-09-10 21:50:40 +02:00
elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "$OS" = "Fedora Linux" ] || [ "${UPSTREAM_ID}" = "rhel" ] || [ "$OS" = "Almalinux" ] || [ "$OS" = "Rocky*" ] ; then
2023-10-23 22:02:40 +02:00
wget https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-0.x86_64.rpm
yum localinstall ./rustdesk-1.2.3-0.x86_64.rpm -y > null
2023-08-21 21:46:01 +02:00
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
2023-08-24 18:11:12 +02:00
rustdesk --password $rustdesk_pw &> /dev/null
2023-08-21 21:46:01 +02:00
2023-08-24 18:11:12 +02:00
rustdesk --config $rustdesk_cfg
2023-08-21 21:46:01 +02:00
systemctl restart rustdesk
echo "..............................................."
# Check if the rustdesk_id is not empty
if [ -n "$rustdesk_id" ]; then
2023-10-01 13:52:30 +02:00
echo "RustDesk ID: $rustdesk_id"
2023-08-21 21:46:01 +02:00
else
2023-10-01 13:52:30 +02:00
echo "Failed to get RustDesk ID."
2023-08-21 21:46:01 +02:00
fi
# Echo the value of the password variable
2023-09-10 21:47:07 +02:00
echo "Password: $rustdesk_pw"
2023-08-21 21:46:01 +02:00
echo "..............................................."
```