Page 1 of 1

[SOLVED] http_proxy setting no effect (yum)

Posted: 2011/12/14 09:01:55
by jack
I am setting correctly for yum's proxy and proxy username and password, but still get HTTP Error 407. If I am right, HTTP Error 407 means need proxy auth.
(1)I have centos6 installed in Oracle virtualbox. the host is windows xp.
(2)I use bridged for centos6.
(3)Both windows xp and centos6 using proxy to connect to internet(our company using proxy 172.20.20.237:8080).
(4)I can open the www.centos.com via Firfox in centos6.


I have problem with the following command:

[root@localhost ~]# yum install telnet-server

the result:

Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=i386&repo=os error was
14: HTTP Error 407 : http://mirrorlist.centos.org/?release=6&arch=i386&repo=os
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=i386&repo=extras error was
14: HTTP Error 407 : http://mirrorlist.centos.org/?release=6&arch=i386&repo=extras
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=i386&repo=updates error was
14: HTTP Error 407 : http://mirrorlist.centos.org/?release=6&arch=i386&repo=updates
http://mirror.ta139.com/centos/6.1/os/i386/repodata/repomd.xml: [Errno 14] HTTP Error 407 : http://mirror.ta139.com/centos/6.1/os/i386/repodata/repomd.xml
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again


the /root/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

http_proxy="http://London\Tom Yang:Password1234x@172.20.20.237:8080"
export http_proxy
~
~
~
~
~
~
~
~

the file /etc/yum.repos.d/CentOS-Base.repo

# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=Cent-OS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirror.ta139.com/centos/6.1/os/i386
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
~
~
~



the file /etc/yum.conf

[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=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
#proxy=http://172.20.20.237:8080/
#proxy_username=London\Tom Yang
#proxy_password=Password1234x

# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking




the file /etc/resolv.conf

# Generated by NetworkManager
domain shanghai.lom.com
search shanghai.lom.com
nameserver 172.20.11.10
nameserver 8.8.8.8 #this line is added by me
~
~
~




I search the internet, HTTP Error 407 means need proxy auth, but I have offered correct name and password.
The name is: London\Tom Yang, there is a space between Tom and Yang, and also there is London\ prefix, is this cause the auth failed?
but when I open page in the Firefox, I put the same username and password, it auth is ok and the request page opened.

Anyone can help me?

Thanks a lot.

Re: http_proxy setting no effect (yum)

Posted: 2011/12/14 09:42:08
by r_hartman
Welcome to the CentOS fora.

I found that in CentOS6 yum will not use the global proxy settings, so I had to specify the proxy explicitly in /etc/yum.conf. So you'll need to remove the '#'.
You can tell firefox to [i]Use system proxy settings[/i], if you set those (System --> Preferences --> Network Proxy), or specify your proxy separately.

However, as your company network appears to be using a Redmond-based proxy, authentication might require NTLMv2, and I found that incorporating your domain name into your credentials, like you have done, does not work.

The solution I use is cntlm, which is in epel.

You can install it on your VM, configure it to use your company proxy and then tell your VM to use localhost.
That way, CentOS will address the cntlm proxy, which in turn addresses your company proxy, providing the desired credentials. No need for credentials in /etc/yum.conf or system/firefox proxy settings anymore.

Only drawback is that, when you need to change your Windows password, you need to remember to change your /etc/cntlm.conf to reflect the new password. That would be no different from having a password in /etc/yum.conf. On the plus side, cntlm allows you to specify the NTLMv2 password hash, avoiding clear-text passwords in the config file.

Re: http_proxy setting no effect (yum)

Posted: 2011/12/14 09:51:51
by TrevorH
The correct place to specify proxy details for yum is in /etc/yum.conf and yours are there but commented out. I suspect that you may need to escape the problematic fields in your username using one of the following

[code]
proxy_username=London\\Tom\ Yang
proxy_username=London\Tom%20Yang
proxy_username=London%5cTom%20Yang
proxy_username="London\Tom Yang"
[/code]

Re: http_proxy setting no effect (yum)

Posted: 2011/12/19 10:38:36
by jack
Thanks.
I installed epel "su -c 'rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm'"
but still cannot connect to the internet, so I download the cntlm manually via firefox.
http://mirror.neu.edu.cn/fedora/epel/5/SRPMS/
http://mirror.neu.edu.cn/fedora/epel/5/SRPMS/cntlm-0.35.1-5.el5.src.rpm

but failed to install cntlm because seems lack of dependence.

and Seting 4 kinds of proxy_username still failed to connect.

[SOLVED] http_proxy setting no effect (yum)

Posted: 2011/12/19 14:55:33
by pschaff
You need to fix your connectivity issues before you can hope to do anything with repositories. Have you corrected the proxy settings?

When you do get there, do not try to install source RPMS unless you intend to rebuild the binaries yourself. Install from the repos and you will get the proper binaries for your architecture.

Re: http_proxy setting no effect (yum)

Posted: 2011/12/22 08:28:31
by jack
Hi, I have solved this problem. Using cntlm is a way.

(1)I download the cntlm form http://cntlm.sourceforge.net/
(2)install cntlm in centos6
(3)edit /etc/cntlm.conf
[code]
Username tom yang
Domain london
#Password password
Auth NTLMv2
PassNTLMv2 9FAEDDE053118078D3B57D109A5FC236
Proxy 152.20.20.27:8080
[/code]
#please note, do not prefix uesrname with domain, like londo\tom yang.

(4)edit /etc/yum.conf[code]
proxy=http://127.0.0.1:3128/
# comment username and password
[/code]
(5)start cntlm

now it ok for yum.

Thanks for you help!
[Moderator edit: Added [i]code[/i] tags to preserve formatting.]

Re: [SOLVED] http_proxy setting no effect (yum)

Posted: 2011/12/22 11:28:30
by pschaff
Interesting - did not know about that one, and missed your point earlier, but I see there is an EPEL package that would probably be preferable to a [url=http://wiki.centos.org/PackageManagement/SourceInstalls]Source Install.[/url]

[code]
# yum --enablerepo epel info Cntlm
Available Packages
Name : cntlm
Arch : x86_64
Version : 0.35.1
Release : 4.el6
Size : 65 k
Repo : epel
Summary : Fast NTLM authentication proxy with tunneling
URL : http://cntlm.sourceforge.net/
License : GPLv2+
Description : Cntlm is a fast and efficient NTLM proxy, with support for TCP/IP
: tunneling, authenticated connection caching, ACLs, proper daemon
: logging and behavior and much more. It has up to ten times faster
: responses than similar NTLM proxies, while using by orders or
: magnitude less RAM and CPU. Manual page contains detailed
: information.
[/code]
The procedure would be to download and install the binary package and any EPEL dependencies, not the source as you tried, from an EPEL mirror and install locally with rpm or yum, using the [c6-media] repo if necessary for dependencies from the OS repos.

Thanks for reporting back. Marking this thread [SOLVED] for posterity.

Re: http_proxy setting no effect (yum)

Posted: 2011/12/23 16:06:42
by r_hartman
[quote]
jack wrote:
http://mirror.neu.edu.cn/fedora/epel/[b]5[/b]/SRPMS/
http://mirror.neu.edu.cn/fedora/epel/[b]5[/b]/SRPMS/cntlm-0.35.1-5.[b]el5[/b].src.rpm
[/quote]
It would appear you downloaded the CentOS[b]5[/b] SRPM; you'd need the CentOS[b]6[/b] one. Hence the dependency issues.

Going with the (proper) repo is much, much preferred over compiling from source, for a ton of reasons.