abetrwy has asked for the wisdom of the Perl Monks concerning the following question:
Need to send a file after I run a nightly cron to another server via SFTP/SSH. After doing a lot of reading here and other places I decided to forgo Net::SSH2 or Net::SFTP or Net::OpenSSH and went with: Net::OpenSSH::Compat::SSH2
It seems debug does not work. Anyway, I get a disconnect error at ->auth_password(). But, I can use Eclipse via ssh and sftp and login, I can use Winscp as well with the same credentials, so I know they are correct.
I am on - Ubuntu 12.04.1 LTS and I have OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
%connection_details = ( host => '<IP>', user => '<USER>', pass => '<PASS>', port => '<PORT>', ); $SFTP = &SFTP_connection(%connection_details); exit (0); sub SFTP_connection { my (%connection_info) = @_; use Net::OpenSSH::Compat::SSH2 qw(:supplant); use Net::SSH2; eval { require Net::SSH2; }; if ($@) { print "The Net::SSH2 or Net::OpenSSH::Compat::SSH2 Perl module + is not installed on this server, which is required for this feature. +\n Please contact your server administrator and ask them t +o install this module.\n"; return 0; } ## Connect to the sFTP server my $SFTP = Net::SSH2->new(); $SFTP->connect($connection_info{'host'},22) or die "Unable to connect to the remote sFTP server \n\n $@"; ## Login to sFTP server $SFTP->auth_password($connection_info{'user'},$connection_info{'pa +ss'}) or die "Unable to login Check username and password. \n\n $@\n +"; return $SFTP; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Help with Net::OpenSSH::Compat::SSH2
by 7stud (Deacon) on Mar 15, 2013 at 03:31 UTC | |
Re: Help with Net::OpenSSH::Compat::SSH2
by salva (Canon) on Mar 15, 2013 at 08:41 UTC | |
Re: Help with Net::OpenSSH::Compat::SSH2
by Illuminatus (Curate) on Mar 15, 2013 at 00:26 UTC | |
Re: Help with Net::OpenSSH::Compat::SSH2
by kielstirling (Scribe) on Mar 15, 2013 at 00:13 UTC |
Back to
Seekers of Perl Wisdom