Linux Agent Installation

Use this guide to control a Linux machine (Ubuntu/Debian/Mint) remotely. Note that X11 Display Server is required (Wayland support is experimental).

⚠️ Critical Warning: Do Not Lock Yourself Out
If you are installing this on a remote VPS via SSH or another remote tool, do not stop the Agent manually once you connect via Rederel.

If the Agent process stops, the connection closes immediately. If you have no other way to access the server (like SSH), you will be locked out permanently.
Recommendation: Use the "Auto-Restart" script or Systemd service described in Section 4 to ensure the Agent respawns if it crashes or stops.

1. Quick Install (Binaries)

If you already have the pre-compiled binary (`rederel_agent_linux`), simply download it and make it executable.

# 1. Download/Copy the binary to your Linux machine
# (Ensure you are in a folder you have write access to)

# 2. Make it executable
chmod +x rederel_agent_linux

# 3. Run it
./rederel_agent_linux

2. Building from Source (Ubuntu 20.04/24.04)

If you are building the agent yourself on a fresh VPS, follow these exact steps to avoid common Python and Clipboard errors.

Step 1: Install System Dependencies

You must install specific headers for X11, Tkinter, and Clipboard management before compiling.

sudo apt update
sudo apt install -y build-essential libffi-dev pkg-config \
  libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxtst-dev \
  tk-dev tcl-dev xsel xclip

Step 2: Compiling Python 3.12 (Correctly)

Standard builds often miss Shared Libraries or Tkinter support. Build it exactly like this:

cd /usr/src
wget https://www.python.org/ftp/python/3.12.8/Python-3.12.8.tgz
tar xzf Python-3.12.8.tgz
cd Python-3.12.8

# Clean any previous bad builds
make clean

# Configure with SHARED libraries and Optimizations
./configure --enable-optimizations --enable-shared

# Compile and Install
make -j$(nproc)
make altinstall
ldconfig /usr/local/lib

Step 3: Verify Installation

Ensure `ctypes` and `tkinter` are active before proceeding.

/usr/local/bin/python3.12 -c "import ctypes; import tkinter; print('SUCCESS: Core modules working')"

Step 4: Build the Agent

Create the virtual environment and compile the binary.

# Setup Venv
mkdir /opt/linux_agent_build
cd /opt/linux_agent_build
/usr/local/bin/python3.12 -m venv venv
source venv/bin/activate

# Install Libraries
pip install mss pynput pillow pyperclip requests pyinstaller

# Compile (Adjust path to your agent.py)
pyinstaller --onefile --clean \
  --name rederel_agent_linux \
  --add-data "shared:shared" \
  --hidden-import=pynput.keyboard._xorg \
  --hidden-import=pynput.mouse._xorg \
  agent.py

3. Troubleshooting

Error: "Pyperclip could not find a copy/paste mechanism"

Symptoms
The logs show clipboard errors, or Copy/Paste from the Browser to the Linux Desktop fails.

Cause: Linux requires an external tool to handle clipboard operations.

The Fix: Install `xsel` (preferred) or `xclip`.

sudo apt install -y xsel

Error: "No module named '_ctypes'" or "tkinter"

Symptoms
PyInstaller fails, or the agent crashes immediately upon launch with a ModuleNotFoundError.

Cause: Python was compiled before the system libraries (`libffi-dev`, `tk-dev`) were installed.

The Fix: You must install the dependencies in "Step 1" above, and then re-compile Python from scratch (Step 2).

4. Production Setup (Auto-Restart)

To ensure you don't get locked out, use a script that automatically restarts the agent if it stops.

# Create start_loop.sh
nano start_loop.sh

# Paste this content:
#!/bin/bash
while true; do
  echo "Starting Agent in 5sec ..."
  sleep 5
  ./dist/rederel_agent_linux
  echo "Agent stopped. Restarting in 10 seconds..."
  sleep 5
done

# Make executable and run
chmod +x start_loop.sh
./start_loop.sh