CPAN:如何克服“请用USER和PASS登录”。 “被动模式被拒绝了。”错误?

时间:2010-11-08 16:29:57

标签: perl install cpan perl-module

如何克服“请使用USER和PASS登录”。 “被动模式被拒绝了。”错误? - 尝试从cpan shell / cpan>中安装CPAN模块时提示

从输出日志到终端,它似乎能够从我的工作服务器连接到外部Perl / CPAN ftp站点,但是远程机器要求输入用户名/密码,并且由于我处于被动状态而拒绝连接模式。

(我已经单独测试了ftp.perl.org,并且能够成功登录用户:匿名密码:匿名)

所以,

  1. 在哪里可以将CPAN程序的用户名/密码提供给这台远程perl / cpan机器? (我假设用户名是:匿名,密码:匿名)
  2. 我在哪里设置说我处于正确的模式(被动/非被动),以便远程perl / cpan机器接受我的连接
  3. 解决这些问题后我还应该做些什么?
  4. 下面的终端输出,然后是我服务器上CPAN文件夹中的Config.pm。

    我的机器是CentOS Linux机器。

    我正在尝试成功安装Date :: Calc - 我的最终目标。感谢。

    在此处和互联网上搜索后找不到任何答案。

    # cpan
    Terminal does not support AddHistory.
    
    cpan shell -- CPAN exploration and modules installation (v1.7602)
    ReadLine support available (try 'install Bundle::CPAN')
    
    cpan> install Date::Calc
    CPAN: Storable loaded ok
    Going to read /root/.cpan/Metadata
    Warning: Found only 0 objects in /root/.cpan/Metadata
    CPAN: LWP::UserAgent loaded ok
    Fetching with LWP:
      ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
    LWP failed with code[404] message[File '01mailrc.txt.gz' not found]
    Fetching with Net::FTP:
      ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
    Couldn't fetch 01mailrc.txt.gz from ftp.perl.org
    
    Trying with "/usr/bin/links -source" to get
        ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
    ELinks: FTP file error
    
    System call "/usr/bin/links -source "ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz"  > /root/.cpan/sources/authors/01mailrc.txt"
    returned status 1 (wstat 256)
    Warning: expected file [/root/.cpan/sources/authors/01mailrc.txt.gz] doesn't exist
    
    Trying with "/usr/bin/wget -O -" to get
        ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
    --2010-11-08 15:50:51--  ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
               => `-'
    Resolving ftp.perl.org... 64.27.65.115, 168.143.19.69
    Connecting to ftp.perl.org|64.27.65.115|:21... connected.
    Logging in as anonymous ... Logged in!
    ==> SYST ... done.    ==> PWD ... done.
    ==> TYPE I ... done.  ==> CWD /pub/CPAN/authors ... done.
    ==> SIZE 01mailrc.txt.gz ... 174301
    ==> PASV ... done.    ==> RETR 01mailrc.txt.gz ...
    No such file `01mailrc.txt.gz'.
    
    
    System call "/usr/bin/wget -O - "ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz"  > /root/.cpan/sources/authors/01mailrc.txt"
    returned status 1 (wstat 256)
    Warning: expected file [/root/.cpan/sources/authors/01mailrc.txt.gz] doesn't exist
    Issuing "/usr/bin/ftp -n"
    Trying 64.27.65.115...
    usage: user username [password] [account]
    Local directory now /root/.cpan/sources/authors
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Passive mode refused.
    Bad luck... Still failed!
    Can't access URL ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz.
    
    Please check, if the URLs I found in your configuration file
    (ftp://ftp.perl.org/pub/CPAN/) are valid. The urllist can be edited. E.g.
    with 'o conf urllist push ftp://myurl/'
    
    Could not fetch authors/01mailrc.txt.gz
    Fetching with LWP:
      ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
    LWP failed with code[404] message[File '02packages.details.txt.gz' not found]
    Fetching with Net::FTP:
      ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
    Couldn't fetch 02packages.details.txt.gz from ftp.perl.org
    
    Trying with "/usr/bin/links -source" to get
        ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
    ELinks: FTP file error
    
    System call "/usr/bin/links -source "ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz"  > /root/.cpan/sources/modules/02packages.details.txt"
    returned status 1 (wstat 256)
    Warning: expected file [/root/.cpan/sources/modules/02packages.details.txt.gz] doesn't exist
    
    Trying with "/usr/bin/wget -O -" to get
        ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
    --2010-11-08 15:51:12--  ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
               => `-'
    Resolving ftp.perl.org... 64.27.65.115, 168.143.19.69
    Connecting to ftp.perl.org|64.27.65.115|:21... connected.
    Logging in as anonymous ... Logged in!
    ==> SYST ... done.    ==> PWD ... done.
    ==> TYPE I ... done.  ==> CWD /pub/CPAN/modules ... done.
    ==> SIZE 02packages.details.txt.gz ... 950491
    ==> PASV ... done.    ==> RETR 02packages.details.txt.gz ...
    No such file `02packages.details.txt.gz'.
    
    
    System call "/usr/bin/wget -O - "ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz"  > /root/.cpan/sources/modules/02packages.details.txt"
    returned status 1 (wstat 256)
    Warning: expected file [/root/.cpan/sources/modules/02packages.details.txt.gz] doesn't exist
    Issuing "/usr/bin/ftp -n"
    Trying 64.27.65.115...
    usage: user username [password] [account]
    Local directory now /root/.cpan/sources/modules
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Passive mode refused.
    Bad luck... Still failed!
    Can't access URL ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz.
    
    Please check, if the URLs I found in your configuration file
    (ftp://ftp.perl.org/pub/CPAN/) are valid. The urllist can be edited. E.g.
    with 'o conf urllist push ftp://myurl/'
    
    Could not fetch modules/02packages.details.txt.gz
    Fetching with LWP:
      ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
    LWP failed with code[404] message[File '03modlist.data.gz' not found]
    Fetching with Net::FTP:
      ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
    Couldn't fetch 03modlist.data.gz from ftp.perl.org
    
    Trying with "/usr/bin/links -source" to get
        ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
    ELinks: FTP file error
    
    System call "/usr/bin/links -source "ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz"  > /root/.cpan/sources/modules/03modlist.data"
    returned status 1 (wstat 256)
    Warning: expected file [/root/.cpan/sources/modules/03modlist.data.gz] doesn't exist
    
    Trying with "/usr/bin/wget -O -" to get
        ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
    --2010-11-08 15:51:31--  ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
               => `-'
    Resolving ftp.perl.org... 64.27.65.115, 168.143.19.69
    Connecting to ftp.perl.org|64.27.65.115|:21... connected.
    Logging in as anonymous ... Logged in!
    ==> SYST ... done.    ==> PWD ... done.
    ==> TYPE I ... done.  ==> CWD /pub/CPAN/modules ... done.
    ==> SIZE 03modlist.data.gz ... 182988
    ==> PASV ... done.    ==> RETR 03modlist.data.gz ...
    No such file `03modlist.data.gz'.
    
    
    System call "/usr/bin/wget -O - "ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz"  > /root/.cpan/sources/modules/03modlist.data"
    returned status 1 (wstat 256)
    Warning: expected file [/root/.cpan/sources/modules/03modlist.data.gz] doesn't exist
    Issuing "/usr/bin/ftp -n"
    Trying 64.27.65.115...
    usage: user username [password] [account]
    Local directory now /root/.cpan/sources/modules
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Please login with USER and PASS.
    Passive mode refused.
    Bad luck... Still failed!
    Can't access URL ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz.
    
    Please check, if the URLs I found in your configuration file
    (ftp://ftp.perl.org/pub/CPAN/) are valid. The urllist can be edited. E.g.
    with 'o conf urllist push ftp://myurl/'
    
    Could not fetch modules/03modlist.data.gz
    Going to write /root/.cpan/Metadata
    Warning: Cannot install Date::Calc, don't know what it is.
    Try the command
    
        i /Date::Calc/
    
    to find objects with matching identifiers.
    

    /usr/lib/perl5/5.8.8/CPAN/Config.pm: -

    # This is CPAN.pm's systemwide configuration file. This file provides
    # defaults for users, and the values can be changed in a per-user
    # configuration file. The user-config file is being looked for as
    # ~/.cpan/CPAN/MyConfig.pm.
    
    $CPAN::Config = {
      'build_cache' => q[10],
      'build_dir' => q[/root/.cpan/build],
      'cache_metadata' => q[1],
      'cpan_home' => q[/root/.cpan],
      'dontload_hash' => {  },
      'ftp' => q[/usr/bin/ftp],
      'ftp_proxy' => q[],
      'getcwd' => q[cwd],
      'gpg' => q[/usr/bin/gpg],
      'gzip' => q[/bin/gzip],
      'histfile' => q[/root/.cpan/histfile],
      'histsize' => q[100],
      'http_proxy' => q[],
      'inactivity_timeout' => q[0],
      'index_expire' => q[1],
      'inhibit_startup_message' => q[0],
      'keep_source_where' => q[/root/.cpan/sources],
      'links' => q[/usr/bin/links],
      'make' => q[/usr/bin/make],
      'make_arg' => q[],
      'make_install_arg' => q[],
      'makepl_arg' => q[],
      'ncftp' => q[],
      'ncftpget' => q[],
      'no_proxy' => q[],
      'pager' => q[/usr/bin/less],
      'prerequisites_policy' => q[ask],
      'scan_cache' => q[atstart],
      'shell' => q[/bin/bash],
      'tar' => q[/bin/tar],
      'term_is_latin' => q[1],
      'unzip' => q[/usr/bin/unzip],
      'urllist' => [q[ftp://ftp.perl.org/pub/CPAN/]],
      'wget' => q[/usr/bin/wget],
    };
    1;
    __END__
    

    更新

    回应daxim对他回答的评论:“你可以编辑评论。 - 编辑Config.pm,关键urllist是字符串的arrayref;或者在CPAN提示下运行o conf urllist。 - daxim 16小时前” - 我在下面尝试了你的建议,daxim:

    首先我尝试了:

      cpan> o conf urllist
        urllist
            ftp://ftp.perl.org/pub/CPAN/
    Type 'o conf' to view configuration edit options
    

    以下说明(即标题为“更改列表值:o conf KEY SHIFT | UNSHIFT | PUSH | POP | SPLICE | LIST”标题下的第3个示例项目符号)http://search.cpan.org/~andk/CPAN-1.9402/lib/CPAN.pm#changing添加一个http镜像:{{3 }}

    cpan> o conf urllist http://mirror.ox.ac.uk/sites/www.cpan.org/ ftp://ftp.perl.org/pub/CPAN/
    
    cpan> o conf urllist
        urllist
            ftp://ftp.perl.org/pub/CPAN/
    Type 'o conf' to view configuration edit options
    
    
    cpan>
    

    所以从上面来看,我没有添加我的HTTP镜像。有人可以提供一些建议吗?

    然后我尝试了:“编辑Config.pm,关键urllist是字符串的arrayref;”:

    Config.pm中的相关代码段为:

     'urllist' => [q[ftp://ftp.perl.org/pub/CPAN/]],
      'wget' => q[/usr/bin/wget],
    

    我的arrayref如何看待这里 - 我的镜像列表。请告诉我应该如何编辑它。

    更新2:

    http://www.cpan.org/SITES.html(第3个示例项目符号)中给出的向urllist添加URL的说明不完整,即错误,他们错过了推送。成功的命令是:

    [root CPAN]# cpan
    Terminal does not support AddHistory.
    
    cpan shell -- CPAN exploration and modules installation (v1.7602)
    ReadLine support available (try 'install Bundle::CPAN')
    
    cpan> o conf urllist push http://mirror.ox.ac.uk/sites/www.cpan.org/
    
    cpan> o conf urllist
        urllist
            ftp://ftp.perl.org/pub/CPAN/
            http://mirror.ox.ac.uk/sites/www.cpan.org/
    Type 'o conf' to view configuration edit options
    
    
    cpan>
    

    自:

    http://search.cpan.org/~andk/CPAN-1.9402/lib/CPAN.pm#changing

    其他重要事项:

    事先,必须检查是否安装新模块,是否还安装依赖项 - 即其他模块 - 以及它们是否是机器上现有模块的新版本,因此如果它们的行为或界面发生变化会影响现有模块在机器上运行的应用程序:http://www.perlmonks.org/?node_id=551175

    更新3:

    看起来编辑urllist并不是持久性的,因为在上一次退出后重新进入cpan时,只剩下ftp条目。

    cpan> o conf urllist
        urllist
            ftp://ftp.perl.org/pub/CPAN/
    Type 'o conf' to view configuration edit options
    

3 个答案:

答案 0 :(得分:3)

selecting a HTTP mirror克服FTP问题(这是一个非常愚蠢的网络协议)。

答案 1 :(得分:0)

我不确定您为什么会收到用户名/密码提示,但我相信您应该能够通过创建类似于此的~/.netrc文件将其设置为您在上面指定的值/ p>

machine ftp.perl.org
   login anonymous
   password anonymous@cpan.org

或者您可以强制所有ftp请求自动匿名,除非另有说明,将此行放入~/.netrc

default login anonymous password anonymous@cpan.org

我用过的每个FTP客户端和库都尊重.netrc文件。这是一种保持站点密码不受源代码限制的方法,即使它是以纯文本格式保存。

答案 2 :(得分:0)

我认为你误解了这个问题 - 你很快就会遇到错误,例如在行

  

用LWP获取:
    ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
  LWP失败,代码[404]消息[文件'01mailrc.txt.gz'未找到]

您是否在本机和互联网之间设置了代理或防火墙?此连接失败。