我在Cygwin x86中使用Perl 5.14.2,我希望通过ssh连接自动下载Cisco设备的配置文件。 为了建立ssh连接我尝试了两个不同的perl模块,Net :: Telnet和Net :: Appliance :: Session,但我得到了相同的结果:
[ 0.020658] pr finding prompt
[ 0.030873] tr creating Net::Telnet wrapper for ssh
[ 0.033997] tr connecting with: ssh -o StrictHostKeyChecking=no -o UserKnownH
ostsFile=/dev/null -o CheckHostIP=no -l user x.x.x.x
[ 0.176672] du SEEN:
usage: ssh [-1246AaCfghkNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]
[-D port] [-e escape_char] [-F configfile] [-i identity_file]
[-L port:host:hostport] [-l login_name] [-m mac_spec] [-o option]
[-p port] [-R port:ho
[ 0.204828] ph reading phrasebook /usr/lib/perl5/site_perl/5.14/Net/CLI/Inter
act/phrasebook/cisco/pb
[ 0.206988] ph reading phrasebook /usr/lib/perl5/site_perl/5.14/Net/CLI/Inter
act/phrasebook/cisco/ios/pb
[ 0.208445] ph storing prompt generic
[ 0.218928] ph storing prompt basic
[ 0.219794] ph storing prompt privileged
[ 0.220544] ph storing prompt configure
[ 0.221287] ph storing prompt user
[ 0.222011] ph storing prompt pass
似乎Cygwin忽略了perl模块传递给ssh命令的参数。 这是我使用Net :: Appliance :: Session:
的代码 use strict;
use Net::Appliance::Session;
my $host="x.x.x.x";
my $user="user";
my $pass="pass";
my $server="x.x.x.x";
my $fileName="file";
my $ssh = Net::Appliance::Session->new({
personality => 'ios',
transport => 'SSH',
host => $host
});
$ssh->set_global_log_at('debug');
$ssh->connect({username => $user, password => $pass});
#enable password is the same
$ssh->begin_privileged({ password => $pass });
print $ssh->cmd("copy system:/running-config tftp://$server/$fileName");
相反,使用Net :: Telnet的代码与示例部分中此页面中的代码相同: http://search.cpan.org/~jrogers/Net-Telnet-3.04/lib/Net/Telnet.pm
我在Window 7和Windows XP中也尝试过。 可能是什么问题?