syntax for SOCKS proxy in apt.conf

A possible solution can be to use tsocks, an application that can redirect the network traffic through a socks proxy. Install tsocks package, modify /etc/tsocks.conf to set address and port number of your socks proxy, and run:

$ sudo -s
# tsocks apt-get update
# tsocks apt-get dist-upgrade
# exit
$

or

$ sudo -s
# . tsocks -on
# apt-get update
# apt-get dist-upgrade
# . tsocks -off # not really necessary, given the exit
# exit
$

You can think to a number of options, to simplify and automate its use.
Don't forget the leading dot, the Manpage has more deatails on this.

Edit: a shorter way to use it:

$ sudo tsocks apt-get update
$ sudo tsocks apt-get dist-upgrade

Acquire::http::proxy "socks5h://server:port";

This works for me on Ubuntu 18.04. As the man page says, socks5h, not socks5, is supported by apt, which means socks5 proxy with DNS resolving ability.


Using the next config line works for me:

Acquire::socks::proxy "socks5://server:port";

To keep apt.conf clean and avoid problems at Linux upgrade I created a new file (/etc/apt/apt.conf.d/12proxy) and added the config file to it.

Tags:

Proxy

Apt