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; }

In reply to Help with Net::OpenSSH::Compat::SSH2 by abetrwy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.