#!/usr/bin/env python3 """Fetch and authenticate the official PBS 4.2.8-1 static client, then extract it. Run as a normal user. This helper does not change APT configuration, install a Debian package, execute downloaded binaries, or connect to a PBS server. Reviewed against the official Proxmox repository on 2026-10-31. Requires Python 3, gpgv and dpkg-deb (standard Ubuntu/Debian tools). """ import argparse import hashlib from pathlib import Path import platform import subprocess import sys import urllib.request VERSION = "4.2.8-1" BASE = "http://download.proxmox.com/debian/pbs-client/" SUITE = "trixie" KEY_URL = "https://enterprise.proxmox.com/debian/proxmox-archive-keyring-trixie.gpg" # Published at https://pbs.proxmox.com/docs/installation.html#secureapt KEY_SHA256 = "136673be77aba35dcce385b28737689ad64fd785a797e57897589aed08db6e45" PACKAGE_SHA256 = "f20e5dd1565362f2c9bbfa892e4bda04e5e7a8fd9a14ef7c681ca716ac7c4001" BINARY_SHA256 = "0618655ea2f589afd37139e8c774322f17b41734a5239b40cc3b75a41e3929de" def fetch(url, path): with urllib.request.urlopen(url, timeout=60) as response: data = response.read() path.write_bytes(data) return data def verify(data, expected_hash, expected_size=None): if hashlib.sha256(data).hexdigest() != expected_hash: raise ValueError("SHA256 verification failed; stop and investigate") if expected_size is not None and len(data) != expected_size: raise ValueError("Size verification failed; stop and investigate") def fields(stanza): return dict(line.split(": ", 1) for line in stanza.splitlines() if ": " in line and not line.startswith(" ")) def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--output", default="pbs-client-4.2.8-1", help="new directory for authenticated files and extracted binary") args = parser.parse_args() if platform.machine().lower() not in ("x86_64", "amd64"): raise ValueError("This official static package is for x86-64/amd64 Linux") root = Path(args.output).expanduser().resolve() root.mkdir(mode=0o700, parents=True, exist_ok=False) key = root / "proxmox-archive-keyring.gpg" verify(fetch(KEY_URL, key), KEY_SHA256) inrelease = root / "InRelease" fetch(BASE + f"dists/{SUITE}/InRelease", inrelease) release = root / "Release.verified" subprocess.run(["gpgv", "--keyring", str(key), "--output", str(release), str(inrelease)], check=True) expected = None in_sha256 = False index_name = "main/binary-amd64/Packages" for line in release.read_text().splitlines(): if line == "SHA256:": in_sha256 = True continue if in_sha256 and not line.startswith(" "): break if in_sha256: entry = line.split() if len(entry) == 3 and entry[2] == index_name: expected = (entry[0], int(entry[1])) break if expected is None: raise ValueError("Signed Release file does not list the expected Packages index") index = fetch(BASE + f"dists/{SUITE}/{index_name}", root / "Packages") verify(index, *expected) candidates = [fields(s) for s in index.decode().split("\n\n")] selected = [s for s in candidates if s.get("Package") == "proxmox-backup-client-static" and s.get("Version") == VERSION and s.get("Architecture") == "amd64"] if len(selected) != 1: raise ValueError(f"Expected one authenticated static package for version {VERSION}") package = selected[0] filename = f"proxmox-backup-client-static_{VERSION}_amd64.deb" expected_path = f"dists/{SUITE}/main/binary-amd64/{filename}" if package["Filename"] != expected_path or package["SHA256"] != PACKAGE_SHA256: raise ValueError("Package metadata differs from the version reviewed for this guide") deb = root / filename verify(fetch(BASE + expected_path, deb), package["SHA256"], int(package["Size"])) extracted = root / "extracted" subprocess.run(["dpkg-deb", "--extract", str(deb), str(extracted)], check=True) binary = extracted / "usr/bin/proxmox-backup-client" verify(binary.read_bytes(), BINARY_SHA256) (root / "VERIFIED.txt").write_text( f"Version: {VERSION}\nOfficial key SHA256: {KEY_SHA256}\n" "InRelease signature: verified by gpgv\n" "Packages SHA256: verified against signed Release\n" f"Package SHA256: {PACKAGE_SHA256}\n" f"Client binary SHA256: {BINARY_SHA256}\n" ) print(f"Verified official static client {VERSION}") print(f"Binary: {binary}") print(f"SHA256: {BINARY_SHA256}") print("No packages were installed and no system configuration was changed.") if __name__ == "__main__": try: main() except (OSError, ValueError, KeyError, subprocess.CalledProcessError) as error: print(f"ERROR: {error}", file=sys.stderr) sys.exit(1)