This guide shows how to download and install Snap packages through an SSH SOCKS5 proxy on Ubuntu 24.04. This is useful when the Ubuntu server has restricted Internet access but can connect to another Linux host with Internet connectivity.
APT and Snap use separate proxy configurations, so configuring a SOCKS proxy for apt does not automatically configure snapd.
Open an SSH SOCKS Proxy
Create a local SOCKS5 proxy on TCP port 1080 through a remote SSH server:
The SSH options are:
- -D 1080 - creates a local SOCKS proxy on port 1080
- -N - does not start a remote shell
- -f - moves the SSH process to the background after authentication
Check the SOCKS Proxy
Verify that SSH is listening locally on port 1080:
The expected listener should be on 127.0.0.1:1080.
Configure Snap to Use the SOCKS Proxy
Configure both HTTP and HTTPS Snap traffic to use the local SOCKS5 proxy:
Using socks5h allows hostname resolution to be performed through the SOCKS proxy instead of depending on direct DNS access from the local server.
Check the Snap Proxy Configuration
Verify the currently configured proxy settings:
Restart snapd
Restart snapd after changing the proxy configuration:
Install a Snap Package Through the Proxy
Snap commands can now be used normally. In this example, LXD 5.0 is installed from the stable channel:
The successful installation confirms that snapd can access the Snap Store through the SSH SOCKS proxy.
Use Normal Snap Commands
While the proxy is configured, normal Snap operations use the configured proxy:
Disable the Snap Proxy
When direct Internet access is available again, remove both proxy settings:
Verify that the proxy settings have been removed:
Stop the SSH SOCKS Proxy
Find the SSH process listening on port 1080:
Stop the corresponding SSH process when the proxy is no longer needed:
Quick Configuration
The complete configuration can be summarized as: