Added script
This commit is contained in:
1 parent
942160f783
commit
ed9b3e2730
2 files changed
+188
-1
No files matched your search
@@ -1,2 +1,99 @@
|
|||||||
# AnyDesk-Unattended-Setup
|
# AnyDesk Unattended Access Installer for Linux Mint
|
||||||
|
|
||||||
|
A Bash script that installs AnyDesk from the official repository on Linux Mint (and other Debian/Ubuntu-based systems) and sets a password for unattended access.
|
||||||
|
|
||||||
|
## What it does
|
||||||
|
|
||||||
|
1. Verifies it is running as root on an apt-based system.
|
||||||
|
2. Gets the unattended access password (from an environment variable or an interactive prompt).
|
||||||
|
3. Adds the official AnyDesk apt repository and GPG signing key.
|
||||||
|
4. Installs AnyDesk and enables its systemd service.
|
||||||
|
5. Sets the unattended access password via stdin, so it never appears in the process list.
|
||||||
|
6. Prints the AnyDesk ID so you can connect right away.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Linux Mint (tested target), or another Debian/Ubuntu-based distribution
|
||||||
|
- Root access (`sudo`)
|
||||||
|
- Internet access to `keys.anydesk.com` and `deb.anydesk.com`
|
||||||
|
- An **X11** desktop session (the Linux Mint default). AnyDesk does not support Wayland.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Make the script executable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x install_anydesk_unattended.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### Interactive
|
||||||
|
|
||||||
|
You will be prompted for the password twice (input is hidden):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ./install_anydesk_unattended.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### Non-interactive
|
||||||
|
|
||||||
|
Pass the password as an environment variable, useful for automation or deploying to multiple machines:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ANYDESK_PASSWORD='your-long-password' ./install_anydesk_unattended.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that `sudo VAR=value` keeps the value out of the process arguments of the script, but it will still be stored in your shell history. Clear it afterwards, or read the value from a secrets manager or protected file instead:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo ANYDESK_PASSWORD="$(cat /root/anydesk_pw)" ./install_anydesk_unattended.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
On success the script prints something like:
|
||||||
|
|
||||||
|
```
|
||||||
|
AnyDesk installed and unattended access password set.
|
||||||
|
AnyDesk ID: 123456789
|
||||||
|
```
|
||||||
|
|
||||||
|
Use that ID and the password you set to connect from another AnyDesk client.
|
||||||
|
|
||||||
|
## Password requirements
|
||||||
|
|
||||||
|
The script enforces a minimum of **10 characters**. Use a long, unique password.
|
||||||
|
|
||||||
|
## Security recommendations
|
||||||
|
|
||||||
|
- Use a strong, unique password. An exposed AnyDesk ID with a weak password is a common way machines are compromised.
|
||||||
|
- If your AnyDesk plan supports it, enable two-factor authentication and an access control list (allowlist of permitted AnyDesk IDs) in AnyDesk's settings.
|
||||||
|
- Avoid leaving the password in shell history, scripts under version control, or world-readable files.
|
||||||
|
- Disable or uninstall AnyDesk on machines that no longer need remote access.
|
||||||
|
|
||||||
|
## Limitations
|
||||||
|
|
||||||
|
- The machine must be powered on and at the login screen or logged in. AnyDesk cannot wake a sleeping or powered-off machine (use Wake-on-LAN or similar for that).
|
||||||
|
- Wayland sessions are not supported.
|
||||||
|
- Re-running the script is safe: it reinstalls/updates the package, rewrites the repo entry, and resets the password.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
| Problem | Fix |
|
||||||
|
|---|---|
|
||||||
|
| `Failed to set the AnyDesk password` | Make sure the service is running: `sudo systemctl status anydesk`. Then retry. |
|
||||||
|
| AnyDesk ID shows as unavailable | The service may still be starting. Run `anydesk --get-id` after a few seconds. |
|
||||||
|
| Can't connect / black screen | Check you are on an X11 session, not Wayland. At the login screen, select the Cinnamon (X11) session. |
|
||||||
|
| Repo or key download fails | Check network and proxy settings, and that `keys.anydesk.com` and `deb.anydesk.com` are reachable. |
|
||||||
|
|
||||||
|
## Uninstalling
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo systemctl disable --now anydesk
|
||||||
|
sudo apt-get remove --purge -y anydesk
|
||||||
|
sudo rm -f /etc/apt/sources.list.d/anydesk-stable.list /etc/apt/keyrings/anydesk.gpg
|
||||||
|
sudo apt-get update
|
||||||
|
```
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
This script is provided as-is. AnyDesk is a trademark of AnyDesk Software GmbH; this project is not affiliated with or endorsed by AnyDesk. Only use it on systems you own or are authorized to administer.
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# install_anydesk_unattended.sh
|
||||||
|
# Installs AnyDesk on Linux Mint (Ubuntu/Debian based) from the official
|
||||||
|
# repository and sets a password for unattended access.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# sudo ./install_anydesk_unattended.sh
|
||||||
|
# sudo ANYDESK_PASSWORD='YourStrongPassword' ./install_anydesk_unattended.sh
|
||||||
|
#
|
||||||
|
# If ANYDESK_PASSWORD is not set, you will be prompted for it (input hidden).
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ---------- Checks ----------
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "This script must be run as root. Try: sudo $0" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v apt-get >/dev/null 2>&1; then
|
||||||
|
echo "apt-get not found. This script is intended for Linux Mint / Debian / Ubuntu." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---------- Get the password ----------
|
||||||
|
PASSWORD="${ANYDESK_PASSWORD:-}"
|
||||||
|
|
||||||
|
if [[ -z "$PASSWORD" ]]; then
|
||||||
|
read -r -s -p "Enter unattended access password: " PASSWORD
|
||||||
|
echo
|
||||||
|
read -r -s -p "Confirm password: " PASSWORD2
|
||||||
|
echo
|
||||||
|
if [[ "$PASSWORD" != "$PASSWORD2" ]]; then
|
||||||
|
echo "Passwords do not match." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${#PASSWORD} -lt 10 ]]; then
|
||||||
|
echo "Password must be at least 10 characters (use a long, unique one)." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---------- Add the official AnyDesk repository ----------
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y -qq ca-certificates curl gnupg
|
||||||
|
|
||||||
|
install -d -m 0755 /etc/apt/keyrings
|
||||||
|
curl -fsSL https://keys.anydesk.com/repos/DEB-GPG-KEY \
|
||||||
|
| gpg --dearmor --yes -o /etc/apt/keyrings/anydesk.gpg
|
||||||
|
chmod 0644 /etc/apt/keyrings/anydesk.gpg
|
||||||
|
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/anydesk.gpg] https://deb.anydesk.com/ all main" \
|
||||||
|
> /etc/apt/sources.list.d/anydesk-stable.list
|
||||||
|
|
||||||
|
# ---------- Install ----------
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y anydesk
|
||||||
|
|
||||||
|
# ---------- Make sure the service is running ----------
|
||||||
|
systemctl enable --now anydesk.service
|
||||||
|
|
||||||
|
# Give the service a few seconds to initialise
|
||||||
|
for _ in {1..15}; do
|
||||||
|
if anydesk --get-id >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# ---------- Set the unattended access password ----------
|
||||||
|
# The password is piped via stdin so it never appears in the process list.
|
||||||
|
if ! printf '%s\n' "$PASSWORD" | anydesk --set-password; then
|
||||||
|
echo "Failed to set the AnyDesk password." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
unset PASSWORD PASSWORD2
|
||||||
|
|
||||||
|
# ---------- Done ----------
|
||||||
|
ID="$(anydesk --get-id 2>/dev/null || echo 'unavailable (try again in a moment)')"
|
||||||
|
echo
|
||||||
|
echo "AnyDesk installed and unattended access password set."
|
||||||
|
echo "AnyDesk ID: $ID"
|
||||||
|
echo
|
||||||
|
echo "Notes:"
|
||||||
|
echo " - Linux Mint should use an X11 session (the default); AnyDesk does not support Wayland."
|
||||||
|
echo " - To connect after a reboot, the machine must be on and at the login screen or logged in."
|
||||||
Reference in new issue
Block a user