Running Commands behind Proxy

How to run Linux Commands like apt,wget,git,pip etc behind a proxy

0xsanz
2 min readDec 27, 2021

--

https://commons.wikimedia.org/wiki/File:Forward_proxy_h2g2bob.svg

Introduction

Most of the Companies use some kind of proxy(like squid proxy) to monitor,filter the internet traffic out of then Internal Network. Usually this works OK, but sometimes some tools which we will list below cannot be downloaded until use the proxy address. This write-up is a collection of some of these tools and commands to help us to download the tools.Assumption here is that you already know the IP Address:Port where the proxy is running and you are running these commands as “root”.

Git behind a proxy

First set the proxy and then run the git clone command:

export https_proxy=export https_proxy=http://192.168.10.10:3128
git clone https://github.com/diego-treitos/linux-smart-enumeration.git

These are example IP Address and git repo, replace them with what you own proxy IP and Port and the repo.

Apt behind a proxy

Commands:

http_proxy=http://192.168.10.10:3128 apt update
http_proxy=http://192.168.10.10:3128 apt install clang-9 — install-suggests

Wget behind a proxy

Commands:

wget http://raw.githubusercontent.com/diego-treitos/linux-smart-enumeration/master/lse.sh -e use_proxy=yes -e http_proxy=192.168.10.10:3128

wget https://raw.githubusercontent.com/diego-treitos/linux-smart-enumeration/master/lse.sh -e use_proxy=yes -e https_proxy=192.168.10.10:3128

So as you can see above in certain cases we can replace https with http also.

Yum/Dnf behind a proxy

Append proxy server details to /etc/yum.conf :

proxy=http://192.168.10.10:3128

Then run the command:

yum -y install pykickstart
dnf -y install pykickstart

Pip behind a proxy

Commands:

export http_proxy=http://192.168.10.10:3128
export https_proxy=https://192.168.10.10:3128
pip3 install requests

cURL behind a proxy

Command:

curl --proxy “http://192.168.10.10:3128" “http://www.example.com/"
curl -- proxy “https://192.168.10.10:3128" “https://www.example.com/"

Note: If the proxy is using username and password add in the requests which we made above:

http(s)://username:password@proxyserver:port

More command will be added once I discover them while doing my work :), Thanks for reading.

--

--

0xsanz

Software Developer having keen interest in Security, Privacy and Pen-testing. Certs:- Security+,PenTest+,AZ900,AZ204