CentOS / RHEL / Fedora Linux: Use Yum Command With A Proxy Server

0

My CentOS Linux based laptop can only be accessed through our corporate proxy servers. How do I access and use [main] with a Web proxy server on a CentOS / RHEL / Fedora / Red Hat / Scientific Linux?

Yum repositories can be accessed through standard proxy servers such as Squid proxy server. You need to provide use the following details of the proxy server in /etc/yum.conf file:

  1. proxy=http://URL:PORT/ – Proxy serer URL to the proxy server that yum should use. You must seta complete URL, including the TCP port number. If your corporate proxy server requires a username and password, specify these by adding following two settings in yum.[main] itself.
  2. proxy_username=YOUR-PROXY-USERNAME-HERE (optional)- Your proxy server username to use for the proxy URL.
  3. proxy_password=YOUR-SUPER-secrete-PASSWORD-HERE (optional) – Your proxy server password for this proxy URL.

Configuration: Using yum with a proxy server on a CentOS/RHEL/Fedora Linux

Login as root user and type:
# vi /etc/yum.conf
Add the following settings in [main] section:

 
proxy=http://server1.cyberciti.biz:3128
proxy_username=vivek
proxy_password=secretePassword

Here is a complete config /etc/yum.conf file:

 
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
exclude=lighttpd* nginx* spawn-fcgi* webalizer*
proxy=http://server1.cyberciti.biz:3128
proxy_username=vivek
proxy_password=secretePassword

Save and close the file. Please note that defining a proxy server, username, and password in /etc/yum.conf means that all users connect to the proxy server with those details when using [main]:
# yum update
# yum install httpd php php-gd php-mysql

How do I enable proxy access for a specific user such as root user only?

[main] and applications via the proxy server. Type the following command at shell prompt:
# export http_proxy="http://server1.cyberciti.biz:3128"
OR
# export http_proxy="http://PROXY=USERNAME=HERE:[email protected]:PORT"
# export http_proxy="http://vivek:[email protected]:3128"

You might also like More from author