Blog

Thoughts, experiments, and quiet rants on security, from cloud to code and everything in between.

Selfhosted SOCKS5 Proxy

Create SOCKS5 proxy in a few seconds | Selfhosted Socks5 Proxy Script

Need a lightweight SOCKS5 proxy on a cheap VPS without wrestling with Dante configs, PAM files, and firewall rules? selfhostedSocks5 is an open-source Bash script that installs, secures, and manages a Dante-based SOCKS5 proxy on Debian, Ubuntu, and Alpine Linux in one command.

It is built for extreme low-end environments: 64MB/128MB RAM nodes, LXC containers, and micro-VPS deals where a normal package install would trip the OOM killer. The script handles swap allocation during install, strips log bloat, and ships with SSRF protection so proxy users cannot reach loopback, private networks, or cloud metadata endpoints.

What is a SOCKS5 proxy?

A SOCKS5 proxy establishes a TCP connection to a remote server on behalf of a client and relays traffic between them. Unlike a full VPN tunnel, a SOCKS proxy is application-level and lightweight, useful for routing specific traffic through another host, bypassing restrictive networks, or testing from a different egress IP. For many use cases it is simpler and faster to deploy than a VPN.

Key features

  • Low-end ready: Zero persistent log files, auto-swap on <512MB RAM during install, and Debian 13 (Trixie) package fallbacks.
  • Alpine native: Dedicated script for Alpine's apk and OpenRC.
  • SSRF protection: Blocklists for 127.0.0.0/8, private RFC1918 ranges, and cloud metadata IPs.
  • True user isolation: Proxy users authenticate via a custom passwd file (Debian/Ubuntu) or locked-down system accounts (Alpine), with no SSH access.
  • Secure passwords: 20-character alphanumeric credentials with SHA-512 hashing.
  • Interactive manager: Add/remove users, change ports, list accounts, or fully uninstall from a persistent menu.

Quick install

Debian & Ubuntu:

wget -qO socks5.sh https://raw.githubusercontent.com/mathewskdaniel/selfhostedSocks5/main/socks5.sh && sudo bash socks5.sh

Alpine Linux:

wget -qO alpinesocks5.sh https://raw.githubusercontent.com/mathewskdaniel/selfhostedSocks5/main/alpinesocks5.sh && sudo ash alpinesocks5.sh

On minimal containers running as root without sudo, drop the sudo prefix. After install, the script prints your server IP, port, username, and password. Save the password immediately; hashes are irreversible.

Management dashboard

Re-run the script anytime to open the SOCKS5 Master Manager:

╔══════════════════════════════════╗
║      SOCKS5 Master Manager       ║
╠══════════════════════════════════╣
║ Status: Running                  ║
║ IP:   192.168.69.42              ║
║ Port: 44321                      ║
╠══════════════════════════════════╣
║ 1) List Users                    ║
║ 2) Add New User                  ║
║ 3) Remove a User                 ║
║ 4) Change Global Port            ║
║ 5) Full Uninstall                ║
║ 6) Exit                          ║
╚══════════════════════════════════╝

Compatibility

  • Debian: 11+
  • Ubuntu: 20.04+
  • Alpine: 3.x+
  • Architecture: AMD64 and ARM64
  • Virtualization: KVM, OpenVZ, and LXC

Source, issues, and updates: github.com/mathewskdaniel/selfhostedSocks5 (MIT License).