Install Package using yum via Proxy

Posted on

Sometimes, it is a necessary to install, remove or update package in the host, workstation or server used. There are actually lots of tools or utility which can be used in order to accomplish all the tasks stated before.

In Debian Linuxoperating system distribution or its  variant  such as Ubuntu, Knoppix among several of them, the purpose stated in the beginning can be done using ‘dpkg’ or ‘apt’ as its main package management tool.

In other type of Linux distribution such Redhat Linux operating system distribution or its variant  such as Fedora, CentOS, etc there is a different tool or utility which is used to exercise the task of installing, removing or even updating packages. While ‘rpm’ which is stands for Redhat Package Manager still available to be used there is another package manager that is more popular known as ‘yum’.

This package manager which is called ‘yum’ stands for ‘YellowDog Updater, Modified’. The tool itself is represented with the command ‘yum’. Most of Unix or Linux or any other operating system distribution need to be connected to internet especially on installing or updating process.

Sometimes, there are some policy within the network where we are connected. One of the policy is the existence of proxy server within the network. Every in and out connection must be pass through the proxy server. Including connection from yum which is aiming to directly connect to internet in order to install or update packages. Below is what exactly happened when yum is not properly configured to pass the proxy server when it is trying to connect to the internet for package update or for package installation :

[root@hostname ]# yum search samba-client
Loaded plugins: fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: HTTP Error 401 - Unauthorized
http://mirror.xxxxxxxx.xxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://mirror.xxxxxxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://repo.xxxx.xxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://mirror.xxxxxx.xxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://mirror.xxxxxx.xxx/Centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://mirror.xxxxxxx.xxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://centos.xxx.xxx.xxx/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://xxx.xxxxx.xxxx.xxxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
Could not get metalink http://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=x86_64 error was
14: HTTP Error 401 - Unauthorized
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: HTTP Error 401 - Unauthorized
http://mirror.xxxxx.xxx.xxx/centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://mirror.xxxx.xxx/centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://repo.xxxxx.xxx.xxx/centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://mirror.xxxxx.xxx.xxx/centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://mirror.xxxxxx.xxx/Centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
http://mirror.xxxxxxx.xxx.xx/centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 401 - Unauthorized
Trying other mirror.
...
Could not retrieve mirrorlist https://mirror.xxxx.xxx/yum/el7/x86_64/mirrorlist error was 
14: curl#35 - "TCP connection reset by peer" 
https://xx.xxx.xxx.xxx.xx.xx/yum/el7/x86_64/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer" 
Trying other mirror. 
https://xx.xxx.xxx.xxx.xx.xx/yum/el7/x86_64/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer" 
Trying other mirror. 
https://xx.xxx.xxx.xxx.xxx.xx.xx/yum/el7/x86_64/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer" 
Trying other mirror.

There is an error shown based on the execution of the above output command :

[Errno 14] HTTP Error 401 - Unauthorized

So, there is a solution to handle the above problem. It is done by editing yum configuration file which is located in /etc/yum.conf.
By editing the file specifically adding several lines to inform the proxy server which has to be recognized by yum, assuming the entry and also the entry value are correct, installing package by connecting to the internet using yum via proxy will not be a problem.

[root@hostname backup]# vim /etc/yum.conf

Add the following entry :

proxy=http://url.proxy.xxx.xx.xx:port_number
proxy_username=username
proxy_password=password

Description : 
proxy : the variable holds a role to define the address of proxy server
proxy_username : variable which holds the name for connecting to the proxy server 
username : the value of proxy_username variable, it is the user name used to connect to the proxy server
proxy_password : variable which holds the password for connecting to the proxy server. 
password : the value of proxy_password, it is the corresponding password which can be used together with the value of proxy_username to connect to proxy server. 

Remember to be careful for adding the valid entry in the yum file configuration. This is what happened below if the authentication entry either the username or password value is false.

[root@dws backup]# yum search samba-client
Loaded plugins: fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: HTTP Error 407 - Proxy Authentication Required
http://mirror.xxxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 407 - Proxy Authentication Required
Trying other mirror.
^Chttp://mirror.xxxxxx.xx.xx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 407 - Proxy Authentication Required
Trying other mirror.
http://repo.xxxxxxxx.xxxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 407 - Proxy Authentication Required
Trying other mirror.
http://centos.xxxxxxxxx.xxx.xxxx/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 407 - Proxy Authentication Required
Trying other mirror.
http://mirror.xxxxxx.xxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 407 - Proxy Authentication Required
Trying other mirror.
http://mirror.xxxxxxx.xxx/Centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 407 - Proxy Authentication Required
Trying other mirror.
http://mirror.xxxx.xxxx.xxx.xx.xx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] curl#56 - "Callback aborted"
Trying other mirror.
http://centos.xxx.xxx.xx.xx/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 407 - Proxy Authentication Required
Trying other mirror.
Could not get metalink http://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=x86_64 error was
14: HTTP Error 407 - Proxy Authentication Required
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: HTTP Error 407 - Proxy Authentication Required
http://mirror.xxxxx.xx/centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 407 - Proxy Authentication Required
Trying other mirror.
http://mirror.xxxx.xxxx.xxx.xxx/centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 407 - Proxy Authentication Required
Trying other mirror.

The error is specified with the following message :

[Errno 14] HTTP Error 407 - Proxy Authentication Required

Assuming that the additional entry config in the yum file configuration is correct, this is the output of the command execution  :

[root@hostname ]# yum search samba-client
Loaded plugins: fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: HTTP Error 403 - Forbidden
http://mirror.xxxxxxxx.xxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://xxxxxxxxxxx.xxx.xxx/centos/7.2.1511/os/x86_64/repodata/repomd.xml: (28, 'Operation too slow. Less than 1000
bytes/sec transferred the last 30 seconds')
Trying other mirror.
base                       | 3.6 kB  00:00:00
epel/x86_64/metalink       | 4.8 kB  00:00:00
epel                       | 4.3 kB  00:00:00
extras                     | 3.4 kB  00:00:00
galera                     | 2.9 kB  00:00:00
mysql-connectors-community | 2.5 kB  00:00:00
mysql-tools-community      | 2.5 kB  00:00:00
mysql56-community          | 2.5 kB  00:00:00
pgdg95                     | 3.6 kB  00:00:00
updates                    | 3.4 kB  00:00:00
webtatic                   | 3.6 kB  00:00:00
(1/10): extras/7/x86_64/primary_db               | 160 kB  00:00:00
(2/10): galera/primary_db                        |  14 kB  00:00:00
(3/10): mysql-tools-community/x86_64/primary_db  |  27 kB  00:00:00
(4/10): epel/x86_64/group_gz                     | 170 kB  00:00:01
(5/10): mysql56-community/x86_64/primary_db      | 146 kB  00:00:00
(6/10): webtatic/x86_64/primary_db               | 129 kB  00:00:02
(7/10): epel/x86_64/updateinfo                   | 623 kB  00:00:03
(8/10): updates/7/x86_64/primary_db              | 7.1 MB  00:00:02
(9/10): pgdg95/7/x86_64/primary_db               | 169 kB  00:00:05
(10/10): epel/x86_64/primary_db                  | 4.2 MB  00:00:14
Loading mirror speeds from cached hostfile
* base: xxxxx.xxx.xxxxxxx.xxx.xxx.xx
* epel: xxxx.xxxxxx.xx
* extras: xxxx.xxxxxxx.xxxx.xxx.xxx
* updates: xxxxxx.xxxxxxxx.xxxxx.xx.xx.xx
* webtatic: xxx.xxx.xx.xxx.xx.xx
=======================================================================N/S matched: samba-client =======================================================================
samba-client.x86_64 : Samba client programs
samba-client-libs.i686 : Samba client libraries
samba-client-libs.x86_64 : Samba client libraries

Name and summary matches only, use "search all" for everything.
[root@hostname ]#

As we can see above, the searching process using yum to connect to the internet via proxy has been succeed.

One thought on “Install Package using yum via Proxy

Leave a Reply