[Ssh-sftp-perl-users] Net::SFTP problem in Crypt::DH module
Brought to you by:
dbrobins
From: Prabha A. <pr...@ne...> - 2005-12-06 23:20:09
|
Hello All, I am unable to open a SFTP connection using Net::SFTP - it fails in the = Crypt::DH module. I have the private key on my source server and have = copied the public key to the target server. I am stumped why Crypt::DH = tries to generate a random number when a private key is provided. I went = through the archives of this list and found Rob Verduijn's sample ssh / = sftp code. I hoped that his "magic line" would solve my problem, but it = did not. I saw that Michael Coons had a similar problem earlier but could = not find a post with the solution that worked for him. The error message I = get is below and my code follows it. I am using perl 5.8. Hope someone on = this list can help. Thanks, Prabha =97----error message----- my_host_name: Reading configuration data /export/home/voyager/.ssh/config my_host_name: Reading configuration data /etc/ssh_config my_host_name: Connecting to target_name, port 22. my_host_name: Remote protocol version 1.99, remote software version = OpenSSH_4.0 my_host_name: Net::SSH::Perl Version 1.28, protocol version 2.0. my_host_name: No compat match: OpenSSH_4.0. my_host_name: Connection established. my_host_name: Sent key-exchange init (KEXINIT), wait response. my_host_name: Algorithms, c->s: 3des-cbc hmac-sha1 zlib my_host_name: Algorithms, s->c: 3des-cbc hmac-sha1 zlib Uncaught exception from user code: Didn't read all bytes from urandom at /usr/local/perl/5.8/lib/site_= perl/5.8.7/Crypt/DH.pm line 99, <GEN0> line 1. at /usr/local/perl/5.8/lib/site_perl/5.8.7/Crypt/DH.pm line 99 Crypt::DH::_makerandom(1023) called at /usr/local/perl/5.8/lib/site= _perl/5.8.7/Crypt/DH.pm line 83 Crypt::DH::_makerandom_itv(1023, 1, 'Math::BigInt=3DHASH(0xbdecdc)'= ) called at /usr/local/perl/5.8/lib/site_perl/5.8.7/Crypt/DH.pm line 58 Crypt::DH::generate_keys('Crypt::DH=3DHASH(0xbec0fc)') called at = /usr/local/perl/5.8/lib/site_perl/5.8.7/Net/SSH/Perl/Kex/DH1.pm line 129 Net::SSH::Perl::Kex::DH1::_gen_key('Crypt::DH=3DHASH(0xbec0fc)') = called at /usr/local/perl/5.8/lib/site_perl/5.8.7/Net/SSH/Perl/Kex/DH1.pm = line 107 Net::SSH::Perl::Kex::DH1::_dh_new_group1() called at /usr/local/per= l/5.8/lib/site_perl/5.8.7/Net/SSH/Perl/Kex/DH1.pm line 33 Net::SSH::Perl::Kex::DH1::exchange('Net::SSH::Perl::Kex::DH1=3DHASH= (0x99064c)') called at /usr/local/perl/5.8/lib/site_perl/5.8.7/Net/SSH/Perl= /Kex.pm line 100 Net::SSH::Perl::Kex::exchange('Net::SSH::Perl::Kex::DH1=3DHASH(0x99= 064c)') called at /usr/local/perl/5.8/lib/site_perl/5.8.7/Net/SSH/Perl/SSH2= .pm line 87 Net::SSH::Perl::SSH2::_login('Net::SSH::Perl::SSH2=3DHASH(0x9906ac)= ') called at /usr/local/perl/5.8/lib/site_perl/5.8.7/Net/SSH/Perl/SSH2.pm = line 66 Net::SSH::Perl::SSH2::login('Net::SSH::Perl::SSH2=3DHASH(0x9906ac)'= , 'voyager') called at /export/home/voyager/perl/sftptest2.pl line 39 =97------end error message------- I have replaced the actual hostname and userid with < > in the the code = below.=20 #!/usr/local/bin/perl-5.8 use warnings; use strict; use diagnostics; use Net::SSH::Perl; use Net::SFTP; # 0 =3D debug off 1 =3D debug on my $debug=3D"1"; my $host=3D"<my host name>"; my $out; my $err; my $exit; my $iddsafile =3D "<home dir>/.ssh/id_dsa"; my %ssh_args =3D ( protocol =3D> "2", compression =3D> "1", debug =3D> $debug, interactive =3D> "false", ); my %sftp_args =3D ( user =3D> "<my userid>", debug =3D> $debug, ssh_args =3D> \%ssh_args, #<-magic line for key-exchange ); # the line with the reference to the %ssh_args imports the settings you # need to point sftp to the keys needed for key authentication # set up ssh connection my $ssh =3D Net::SSH::Perl->new($host, %ssh_args); $ssh->login("<my userid>") ; # sending a command to $ssh session ($out, $err, $exit) =3D $ssh->cmd("ls"); # print any output if any print "STDOUT $out\n" if ($out); print "STDERR $err\n" if ($err); print "EXIT $exit\n" if ($exit); # set up sftp connection my $sftp =3D Net::SFTP->new($host, %sftp_args); # sending a file with $sftp ($out, $err, $exit) =3D sftp->put("filesource", "filedestination"); # print any output if any print "STDOUT $out\n" if ($out); print "STDERR $err\n" if ($err); print "EXIT $exit\n" if ($exit); #end code |