17

I have a Linux box in a corporate environment in which web access is gated through a proxy which requires authentication.

During a first run of cpan it auto configures everything that it normally does:

Autoconfigured everything but 'urllist'. Please call 'o conf init urllist' to configure your CPAN server(s) now!

commit: wrote '/usr/lib/perl5/5.10.0/CPAN/Config.pm'

Knowing that I have a proxy to navigate, and having read the docs and several pages on the web about proxy and cpan I:

cpan[1]> o conf init /proxy/

If you're accessing the net via proxies, you can specify them in the CPAN configuration or via environment variables. The variable in the $CPAN::Config takes precedence.

Your ftp_proxy? []

Your http_proxy? [] 10.12.8.9:3128

Your no_proxy? []

If your proxy is an authenticating proxy, you can store your username permanently. If you do not want that, just press RETURN. You will then be asked for your username in every future session.

Your proxy user id? [] my_net_id

Your password for the authenticating proxy can also be stored permanently on disk. If this violates your security policy, just press RETURN. You will then be asked for the password in every future session.

CPAN: Term::ReadKey loaded ok (v2.30) Your proxy password? Please remember to call 'o conf commit' to make the config permanent!

cpan[2]> o conf commit commit: wrote '/usr/lib/perl5/5.10.0/CPAN/Config.pm'

All should be good now, right? So I wish,

cpan[3]> i /Some::Module/ CPAN: Storable loaded ok (v2.18)

I would like to connect to one of the following sites to get 'authors/01mailrc.txt.gz':

http://www.perl.org/CPAN/ ftp://ftp.perl.org/pub/CPAN/

Is it OK to try to connect to the Internet? [yes] LWP not available

Trying with "/usr/bin/curl -L -f -s -S --netrc-optional" to get http://www.perl.org/CPAN/authors/01mailrc.txt.gz curl: (22) The requested URL returned error: 407

System call "/usr/bin/curl -L -f -s -S --netrc-optional "http://www.perl.org/CPAN/authors/01mailrc.txt.gz" > /root/.cpan/sources/authors/01mailrc.txt.tmp29726" returned status 22 (wstat 5632) Warning: expected file [/root/.cpan/sources/authors/01mailrc.txt.gz.tmp29726] doesn't exist

Trying with "/usr/bin/wget -O /root/.cpan/sources/authors/01mailrc.txt.tmp29726" to get http://www.perl.org/CPAN/authors/01mailrc.txt.gz --2012-07-17 15:57:38-- http://www.perl.org/CPAN/authors/01mailrc.txt.gz Connecting to 10.12.8.9:3128... connected. Proxy request sent, awaiting response... 301 Moved Permanently Location: http://www.cpan.org/authors/01mailrc.txt.gz [following] --2012-07-17 15:57:38-- http://www.cpan.org/authors/01mailrc.txt.gz Connecting to 10.12.8.9:3128... connected. Proxy request sent, awaiting response... 407 Proxy Authentication Required 2012-07-17 15:57:38 ERROR 407: Proxy Authentication Required.

So where's the password prompt?

What am I missing to configure cpan to access the internet through the corporate proxy with authentication?

MichaelRpdx
  • 233
  • 1
  • 3
  • 11

4 Answers4

25

you need to provide absolute proxy URL address for configure CPAN proxy settings . don't worry instead of providing simply IP address and port number please provide as given below.

cpan> o conf init /proxy/

Your ftp_proxy? [] ftp://10.12.8.9:3128

Your http_proxy? [] http://10.12.8.9:3128

Your no_proxy? []

and provide username and password if needed (Make sure that you have the downloading permission )

I also have same the issue, but now its working for me. I should also work for you.

BR Jerry James

Rob
  • 26,989
  • 16
  • 82
  • 98
Jerry James
  • 1,125
  • 1
  • 10
  • 17
  • This was the correct answer for me to remove the proxy. Existing docker image/container had an env of http_proxy and I wanted to unset it. – Liam Mitchell Jun 08 '16 at 05:17
9

Install LWP. The cpan utility is using curl, I guess because it couldn't load LWP. No proxy parameters are being passed to curl, so you need the export http_proxy=http://host:port/ before running the command.

Or, if you can install LWP using your distribution's package manager, then it should configure the proxy access correctly.

  • We have a winner. Although it seems like putting the cart before the horse it is possible to install LWP and its 18 dependencies by hand and then cpan will navigate through the proxy. @Luciano has it. – MichaelRpdx Jul 18 '12 at 17:44
  • As an alternative to installing 19 packages from CPAN by hand, try `o conf` setting all three of `http_proxy`, `proxy_user`, and `proxy_pass` to the empty string (or removing them from `~/.cpan/CPAN/MyConfig.pm` with a text editor). Then make sure `HTTP_PROXY`, `HTTPS_PROXY`, and the lower-case variants are set and `export`ed in your shell environment. _This worked for me with a brand new Perl installation from source and a corporate HTTP proxy that requires authentication._ – TheDudeAbides Oct 21 '17 at 01:43
5

You can try using this before calling cpan:

export http_proxy=http://my_net_id:my_net_pwd@10.12.8.9:3128/

This way maybe curl will use the proxy.

Dummy00001
  • 16,630
  • 5
  • 41
  • 63
Paulo
  • 59
  • 1
  • Indeed, the input `10.12.8.9:3128` looks wrong. It should rather say `http://10.12.8.9:3128`. – daxim Jul 18 '12 at 15:21
  • @daxim Note from the logs I posted cpan is connecting to the proxy server, it's just not doing the required authentication – MichaelRpdx Jul 18 '12 at 15:50
0
[root@localhost ~] cpan

Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9800) Enter 'h' for help.

list my download url

cpan[1]> o conf urllist 


urllist
    0 [http://mirror.waia.asn.au/pub/cpan/]
    1 [ftp://mirrors.coopvgg.com.ar/CPAN/]
    2 [http://httpupdate3.cpanel.net/CPAN/]

Type 'o conf' to view all configuration items

add CPAN mirror list

cpan[2]> o conf urllist push http://httpupdate3.cpanel.net/CPAN/

Please use 'o conf commit' to make the config permanent!

commit

cpan[3]> o conf commit

commit: wrote '/root/.cpan/CPAN/MyConfig.pm'

cpan[4]>

now you can install perl module again like : cpan -i Text::Template

Jaimil Patel
  • 1,301
  • 6
  • 13
download
  • 1
  • 1