Using an SSH SOCKS5 Proxy to install packages with yum

This may seem simple to a few of us old-timers (dare I say, greybeards), but kids these days don’t know the struggles of having a network with no default route, or an air-gapped network that needs a bastion host to do anything outside.

So here’s a quick guide to setting up and using yum with a SOCKS5 Proxy, which is supplied with a ssh session.

On the isolated host (ie: the one with no internet access), you want to ssh back to a host that does have internet access, specifying the -D argument. This creates a “Dynamic” port forward, which is basically a SOCKS5 proxy.

ssh -D <localport> <username>@<internethost>

ssh -D 5050 [email protected]

Once logged in, leave that session running and establish another connection to your isolated host. If you disconnect that SSH session with the Dynamic port forward, your SOCKS proxy will drop and this won’t work.

Now, on the isolated host edit your /etc/yum.conf and configure the proxy

proxy=socks5://localhost:5050

This will make yum use the port opened earlier by the SSH session to your internet host as the proxy server.

Now you can yum install whatever you need.