Automate APT-Cacher-NG proxy configuration across Proxmox hosts, LXC containers, and VMs.
Quick (review first):
curl -fsSL https://raw.githubusercontent.com/GrandDay/apt-cache-config/main/install-interactive.sh | bashSafer 2-step (recommended for production):
# 1. Download and review
curl -fsSL https://raw.githubusercontent.com/GrandDay/apt-cache-config/main/install-interactive.sh -o /tmp/install-apt-cache.sh
less /tmp/install-apt-cache.sh # Review the script
# 2. Run after review
bash /tmp/install-apt-cache.sh
rm /tmp/install-apt-cache.shAlternative methods if CDN cache causes issues:
# Method 1: Process substitution
bash <(curl -fsSL https://raw.githubusercontent.com/GrandDay/apt-cache-config/main/install-interactive.sh)
# Method 2: With cache-busting
curl -fsSL "https://raw.githubusercontent.com/GrandDay/apt-cache-config/main/install-interactive.sh?$(date +%s)" | bashThis will:
- Prompt for your APT-Cacher-NG server IP and port
- Ask for SSH configuration preferences
- Optionally accept an existing SSH public key
- Download and configure the script automatically
# 1. Download the script
curl -o /usr/local/bin/connect-to-apt-cache.sh https://raw.githubusercontent.com/GrandDay/apt-cache-config/main/src/connect-to-apt-cache.sh
chmod +x /usr/local/bin/connect-to-apt-cache.sh
# 2. Edit configuration (REQUIRED - set your proxy server IP)
nano /usr/local/bin/connect-to-apt-cache.sh
# Change: APT_PROXY_SERVER="http://YOUR_SERVER_IP:3142"
# 3. Configure your system
connect-to-apt-cache.sh local # Configure current host
connect-to-apt-cache.sh lxc-all # Configure all LXC containers
connect-to-apt-cache.sh vm 10.1.50.10 # Configure a VMThe APT Cache Proxy Configurator is a tool designed to simplify the configuration of Debian/Ubuntu systems to use an APT-Cacher-NG proxy server. This tool helps in speeding up package downloads and reducing bandwidth usage by caching packages.
- SSH Key Management: Automatically checks for existing SSH keys and generates new ones if necessary.
- Flexible Configuration: Supports configuration for local systems, LXC containers, and virtual machines (VMs).
- Interactive Prompts: Provides user-friendly prompts for reconfiguration and SSH key generation.
- Detailed Logging: Outputs color-coded messages for easy identification of operation statuses.
One-liner that prompts for your configuration:
curl -fsSL https://raw.githubusercontent.com/GrandDay/apt-cache-config/main/install-interactive.sh | bashThis interactive installer will ask for your APT-Cacher-NG server details and SSH preferences.
For manual configuration:
curl -o /usr/local/bin/connect-to-apt-cache.sh https://raw.githubusercontent.com/GrandDay/apt-cache-config/main/src/connect-to-apt-cache.sh
chmod +x /usr/local/bin/connect-to-apt-cache.sh
nano /usr/local/bin/connect-to-apt-cache.sh # Edit configurationClone and install from source:
git clone https://github.com/GrandDay/apt-cache-config.git
cd apt-cache-config
./install.shNote: Manual and repository installs require editing the configuration. See the Configuration section below.
This tool writes a single configuration file on target systems:
/etc/apt/apt.conf.d/00aptproxy
Containing:
Acquire::http::Proxy "http://YOUR_SERVER_IP:3142";Why this approach:
- ✅ Safe: Doesn't modify
sources.listor other user configs - ✅ Idempotent: Re-running is safe; checks if already configured
- ✅ Reversible:
removecommand deletes only this file - ✅ Standard: Follows Debian/Ubuntu APT configuration best practices
Important: Your apt-cacher-ng server must have HTTPS pass-through enabled. Add to /etc/apt-cacher-ng/acng.conf:
PassThroughPattern: .*Then restart: systemctl restart apt-cacher-ng
IMPORTANT: Before using the script, you must edit /usr/local/bin/connect-to-apt-cache.sh and customize the configuration variables at the top:
APT_PROXY_SERVER="http://10.1.50.183:3142" # Change to your apt-cacher-ng server
SSH_USER="root" # Change if using different user
SSH_KEY_PATH="$HOME/.ssh/id_rsa" # Path to SSH private key
SSH_PUBLIC_KEY_PATH="$HOME/.ssh/id_rsa.pub" # Path to SSH public key
CUSTOM_SSH_PUBLIC_KEY="" # Optional: paste existing SSH public key# Edit the script
nano /usr/local/bin/connect-to-apt-cache.sh
# Or use sed to update the proxy server
sed -i 's|http://10.1.50.183:3142|http://YOUR_SERVER_IP:3142|' /usr/local/bin/connect-to-apt-cache.shAfter installation, you can use the script to configure your system to use the APT-Cacher-NG proxy. Here are some common commands:
connect-to-apt-cache.sh localconnect-to-apt-cache.sh lxc-single <CTID>connect-to-apt-cache.sh lxc-allconnect-to-apt-cache.sh vm <IP_ADDRESS> [username]connect-to-apt-cache.sh remove <lxc|vm|local> <target>For detailed usage instructions, configuration options, and examples, please refer to the GUIDE.md.
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.
For questions or feedback, please:
- Open an issue: https://github.com/GrandDay/apt-cache-config/issues
- Email: grandday@cue-verse.questt> .