Hi Monks, I'm quite new to Perl. I got stuck with SFTP file transfer.I'm using Net::SFTP module. even though I'm able to list files in remote system SFTP "get" and "put" operations are failing. Code Im using is
#!/usr/bin/perl -w #use strict; use warnings; use Net::SFTP; my $server="XXXXXXXX"; my %args = (ssh_args => { identity_files => [ "/XXXXXXXXXX" ],debug => + 2, } ); $args{debug} = 1; $args{user} = "XXXXXXXX"; my $sftp=Net::SFTP->new($server, %args); $sftp->ls("." , sub { print $_[0]->{longname}, "\n" }); $sftp->put("helloabc.txt", "helloabc.txt"); $sftp->get("S1H62009.txt", "S1H62009.txt"); exit;

Console out put is as follows

AZLDBNJISNDM01: Reading configuration data /home/batchusr/.ssh/config AZLDBNJISNDM01: Reading configuration data /etc/ssh_config AZLDBNJISNDM01: Connecting to XXXXXXX, port 22. AZLDBNJISNDM01: Remote version string: SSH-2.0-WS_FTP-SSH_8.6.1.1504 AZLDBNJISNDM01: Remote protocol version 2.0, remote software version W +S_FTP-SSH_8.6.1.1504 AZLDBNJISNDM01: Net::SSH::Perl Version 2.14, protocol version 2.0. AZLDBNJISNDM01: No compat match: WS_FTP-SSH_8.6.1.1504. AZLDBNJISNDM01: Connection established. AZLDBNJISNDM01: Sent key-exchange init (KEXINIT), waiting for response +. AZLDBNJISNDM01: Using diffie-hellman-group-exchange-sha256 for key exc +hange AZLDBNJISNDM01: Host key algorithm: ssh-rsa AZLDBNJISNDM01: Algorithms, c->s: aes256-ctr hmac-sha2-512 none AZLDBNJISNDM01: Algorithms, s->c: aes256-ctr hmac-sha2-512 none AZLDBNJISNDM01: Entering Diffie-Hellman Group Exchange. AZLDBNJISNDM01: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<4096<8192) sent AZLDBNJISNDM01: Sent DH Group Exchange request, waiting for reply. AZLDBNJISNDM01: Received 2048 bit DH Group Exchange reply. AZLDBNJISNDM01: Generating new Diffie-Hellman keys. AZLDBNJISNDM01: Entering Diffie-Hellman key exchange. AZLDBNJISNDM01: Sent DH public key, waiting for reply. AZLDBNJISNDM01: Received host key, type 'ssh-rsa'. AZLDBNJISNDM01: Host 'XXXXXXXXX' is known and matches the host key. AZLDBNJISNDM01: Verifying server signature. AZLDBNJISNDM01: Send NEWKEYS. AZLDBNJISNDM01: Waiting for NEWKEYS message. AZLDBNJISNDM01: Enabling encryption/MAC/compression. AZLDBNJISNDM01: Sending request for user-authentication service. AZLDBNJISNDM01: Service accepted: ssh-userauth. AZLDBNJISNDM01: Trying empty user-authentication request. AZLDBNJISNDM01: Authentication methods that can continue: publickey,pa +ssword. AZLDBNJISNDM01: Next method to try is publickey. AZLDBNJISNDM01: Trying pubkey authentication with key file 'keypath' AZLDBNJISNDM01: Login completed, opening dummy shell channel. AZLDBNJISNDM01: channel 0: new [client-session] AZLDBNJISNDM01: Requesting channel_open for channel 0. AZLDBNJISNDM01: channel 0: open confirm rwindow 300000 rmax 30000 AZLDBNJISNDM01: channel 1: new [client-session] AZLDBNJISNDM01: Requesting channel_open for channel 1. AZLDBNJISNDM01: Sending subsystem: sftp AZLDBNJISNDM01: Requesting service subsystem on channel 1. AZLDBNJISNDM01: channel 1: open confirm rwindow 300000 rmax 30000 AZLDBNJISNDM01: sftp: Sending SSH2_FXP_INIT AZLDBNJISNDM01: sftp: Remote version: 3 AZLDBNJISNDM01: sftp: Sent message T:11 I:0 AZLDBNJISNDM01: sftp: Sent message T:12 I:1 AZLDBNJISNDM01: sftp: Received reply T:104 I:1 AZLDBNJISNDM01: sftp: Received 67 SSH2_FXP_NAME responses drwxr-x--- 2 ftpadmin ftpadmin 0 Feb 04 08:37 . drwxr-x--- 2 ftpadmin ftpadmin 0 Jan 20 08:36 .. -rwxr-x--- 1 ftpadmin ftpadmin 1 Jan 30 01:52 --v -rwxr-x--- 1 ftpadmin ftpadmin 1 Feb 04 06:43 S1H62009.txt -rwxr-x--- 1 ftpadmin ftpadmin 1 Feb 04 06:37 S1H75009.txt -rwxr-x--- 1 ftpadmin ftpadmin 1 Jan 28 04:34 sftppath AZLDBNJISNDM01: sftp: Sent message T:12 I:2 AZLDBNJISNDM01: sftp: Received reply T:101 I:2 AZLDBNJISNDM01: sftp: Received SSH2_FXP_STATUS 1 AZLDBNJISNDM01: sftp: Sent message T:4 I:3 AZLDBNJISNDM01: sftp: Sent SSH2_FXP_OPEN I:4 P:helloabc.txt Couldn't get handle: Failure at trans.pl line 28. AZLDBNJISNDM01: sftp: Sent message T:17 I:5 AZLDBNJISNDM01: sftp: Received stat reply T:101 I:5 Couldn't stat remote file: Failure at trans.pl line 29.
:( Note: I just hide server/user details from log and code for complaince

In reply to Facing Issue with Net::SFTP by adarsh g u

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.