A Python script to automate the maintenance of RustDesk Server Pro. It solves the critical issue of license slot exhaustion caused by inactive devices or one-time "Quick Support" sessions.
"Built by a SysAdmin, for SysAdmins."
I am a System Integrator, not a professional software developer. I created this tool because we faced a massive issue with our RustDesk license limit in a production environment.
- ⚡ Vibe-Coding: This script was created using AI-Assisted Development (Google Gemini / Google Antigravity).
- 🏭 Battle-Tested: Despite its AI origins, this script is currently running successfully in our live production environment, keeping our license slots clean.
- 🤝 Open Source: I am sharing this so others don't have to pay for license upgrades just because of "dead" clients. If you are a dev, feel free to submit Pull Requests to clean up the code!
In RustDesk Server Pro, every connected device consumes a license slot. This includes:
- Quick Support Clients: Customers you helped once (e.g., via the "Run Only" client).
- Old Devices: Laptops or PCs that haven't been online for months.
These devices remain in your server list as "ungrouped" or inactive entries, permanently blocking a license slot. The RustDesk API does not allow deleting a device directly; it must be disabled first, making manual cleanup tedious.
Reference: RustDesk Server Pro Discussion #182
This script automates the entire cleanup workflow:
- Filter: Finds devices that are ungrouped OR offline for X days.
- Disable: Sends the disable command to the API.
- Delete: Deletes the device to free up the license.
📘 Documentation: Detailed documentation, including Cronjob examples, Filter Options, and CLI arguments, is also available directly inside the
rustdesk_cleaner.pyscript header.
You can install the script either by cloning the repository (recommended for updates) or by downloading the single file directly.
Ensure you have Python 3 and the requests library installed.
# Debian / Ubuntu
sudo apt update && sudo apt install python3 python3-pip
pip3 install requestsBest if you want to keep the script updated easily via git pull.
git clone https://github.com/Smok3y97/Rustdesk-Server-Pro-Device-Cleaner.git
cd Rustdesk-Server-Pro-Device-CleanerBest for quick deployment on a server without downloading git history.
wget https://raw.githubusercontent.com/Smok3y97/Rustdesk-Server-Pro-Device-Cleaner/main/rustdesk_cleaner.py
chmod +x rustdesk_cleaner.pyTo start the script in simulation mode (Dry Run):
python3 rustdesk_cleaner.py delete
⚠️ Important: Before running the script, openrustdesk_cleaner.pyand set yourAPI_URLandAPI_TOKENat the top of the file!