2021-11-26 15:42:51+00:00

For systems administrators maintaining remote Linux terminals or POS machines behind firewalls, setting up screen sharing is critical to debug customer issues. While SSH is powerful, visual debugging of application displays requires GUI-based remote desktop connections. Automating the installation and registration of TeamViewer on headless Linux servers allows teams to provision remote access tools programmatically without requiring manual clicks on-site.

By scripting the deb package installation, binding to system dbus runtimes, and registering hosts to organizational accounts, we can automate TeamViewer provisioning.


1. Automated Installation and Configuration Script

We write a bash script to fetch the package, verify dependencies, and configure TeamViewer to boot headless without showing system popups:

#!/bin/bash
# install_teamviewer.sh
set -euo pipefail

TV_DEB="teamviewer_amd64.deb"
TV_URL="https://download.teamviewer.com/download/linux/$TV_DEB"

echo "Downloading TeamViewer..."
wget -q "$TV_URL" -O "$TV_DEB"

echo "Installing package dependencies..."
sudo apt-get update
sudo apt-get install -y ./$TV_DEB || sudo apt-get install -f -y

# Configure headless daemon options
echo "Configuring TeamViewer settings..."
sudo teamviewer license accept
sudo teamviewer daemon stop

# Modify daemon configurations programmatically
sudo teamviewer passwd "TemporaryAdminPassword123"

# Start the TeamViewer service
sudo teamviewer daemon start
echo "Installation complete!"

2. Binding Remote Access to Organizational Accounts

To access the client terminal without inputting single-use session IDs, we bind the device to a company administrator account using the TeamViewer API command tool:

# Assign device ownership to administrator account
# TV_TOKEN is the registration token from the TeamViewer Management Console
TV_TOKEN="1234567-abcdefghijklmnopqrst"

echo "Registering device assignment..."
sudo teamviewer assignment --id "$TV_TOKEN" --alias "$(hostname)-prod" --group "Production-Edge"

# Print ID to verification logs
teamviewer info | grep "TeamViewer ID"

3. Ensuring Persistent Startup

We configure the TeamViewer daemon to restart automatically following system power losses by setting systemd configuration overrides: systemctl enable teamviewerd.service. This ensures remote gateways regain support accessibility as soon as network interfaces boot.

Unattended Headless Remote Access Provisioning for Industrial Linux Gateways

Automate secure remote support enrollment and token rotation during initial factory flashing of industrial Ubuntu and Raspberry Pi OS gateways.


About the Author — Hire Freelance Programmer Aldian Fazrihady

Aldian Fazrihady is a Top-Rated Senior Freelance Programmer, Freelance Full Stack Developer, and AI Application Engineer with 15+ years of production software engineering experience and Google Cloud Professional Cloud Architect & Data Engineer certifications. He specializes in building custom LLM & autonomous AI agents, RAG pipelines, Next.js/React PWAs, Python (Django/FastAPI), Go microservices, and serverless cloud infrastructure on Google Cloud Run and AWS.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD via Polar) | View Live AI Portfolio | Portfolio Directory | Send a Direct Message

Related Engineering Articles

Freelance Programmer Specializations & Category Hubs