Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Net::SFTP::Foreign gpg file not encrypted

by dsanger (Acolyte)
on Apr 13, 2013 at 16:30 UTC ( [id://1028531]=perlquestion: print w/replies, xml ) Need Help??

dsanger has asked for the wisdom of the Perl Monks concerning the following question:

Monks; I have the following script to send gpg signed and encrypted files to a bank. My problem is the remote end says the files are not encrypted when sent via Net::SFTP::Foreign script. But when sent manually (using SFTP) they same files transfer ok. Would greatly appreciate any help. Thank you in advance.

#!/usr/bin/perl use strict; use warnings; use Net::SFTP::Foreign; # copy .gpg signed/encrypted files to remote host my $sftp = Net::SFTP::Foreign->new( host => 'foo.bar', user => 'username', key_path => '/my/user/.ssh/id_rsa', more => '-v' ); $sftp->mput('/my/user/path/files/*.gpg','remote_directory'); print $sftp->status; exit 0;

Replies are listed 'Best First'.
Re: Net::SFTP::Foreign gpg file not encrypted
by salva (Canon) on Apr 13, 2013 at 16:49 UTC
    I can't see any error on your code. You will have to give us more information: The remote server software, the specific error you get, your OS and SSH client name and version and the Perl and Net::SFTP::Foreign versions. I would like to see also which files are on the source directory.

    Then, activate debugging on the module...

    $Net::SFTP::Foreign::debug = ~(8|16|1024|2048);
    ... and post here the output.

    Finally, in order to check Net::SFTP::Foreign errors usually you don't use status but error, though, for mput you better use the on_error callback.

      remote end (bank) is tight-lipped about their setup. Here's what "version" reports from SFTP prompt:

      remote: sftp> version SFTP protocol version 3

      there is no error reported; I run the script from command line (more => '-v'), files appear to transfer ok.

      Here's my setup:

      CentOS release 6.4 (Final) This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010 Module id = Net::SFTP::Foreign CPAN_USERID SALVA (Salvador Fandino Garcia <salva@cpan.org>) CPAN_VERSION 1.75 CPAN_FILE S/SA/SALVA/Net-SFTP-Foreign-1.75.tar.gz MANPAGE Net::SFTP::Foreign - SSH File Transfer Protocol clien +t INST_FILE /usr/local/share/perl5/Net/SFTP/Foreign.pm INST_VERSION 1.73

      Here's the result of a dry-run (no files) using debug:

      #26678 1366047604.00000 new: This is Net::SFTP::Foreign 1.73 #26678 1366047604.00000 new: Loaded from /usr/local/share/perl5/Net/SF +TP/Foreign.pm #26678 1366047604.00000 new: Running on Perl v5.10.1 for linux #26678 1366047604.00000 new: debug set to 18446744073709548519 #26678 1366047604.00000 new: ~0 is 18446744073709551615 #26678 1366047604.00000 new: Using backend Net::SFTP::Foreign::Backend +::Unix 1.73 #26678 1366047604.00000 _init_transport: ssh cmd: ssh -i /data/home/dp +sppay/.ssh/id_rsa -o PreferredAuthentications=publickey -l ftse3423 - +v fts4.mfts.jpmchase.com -s sftp #26678 1366047604.00000 _queue_msg: queueing msg len: 5, code:1, id:3 +... [1] #26678 1366047604.00000 _get_msg: waiting for message... [1] #26678 1366047604.00000 _do_io: _do_io connected: 1 #26678 1366047604.00000 _do_io: _do_io select(-,-,-, undef) #26678 1366047604.00000 _do_io: _do_io write queue: 9, syswrite: 9, ma +x: 65536, $!: #26678 1366047604.00000 _do_io: _do_io select(-,-,-, undef) OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to foo.com [x.x.x.x] port 22. debug1: Connection established. debug1: identity file /data/home/dpsppay/.ssh/id_rsa type 1 debug1: Remote protocol version 2.0, remote software version SSHD debug1: no match: SSHD debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.3 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client arcfour256 hmac-md5 none debug1: kex: client->server aes128-cbc hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<4096<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host 'foo.com' is known and matches the RSA host key. debug1: Found key in /data/home/dpsppay/.ssh/known_hosts:3 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: password,publickey,keyboard +-interactive debug1: Next authentication method: publickey debug1: Offering public key: /data/home/dpsppay/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 277 debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey). debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 debug1: Sending subsystem: sftp #26678 1366047614.00000 _do_io: _do_io read sysread: 9, total read: 9, + $!: #26678 1366047614.00000 _get_msg: got it!, len:5, code:2, id:-, status +: - #26678 1366047614.00000 DESTROY: Net::SFTP::Foreign=HASH(0x1faa380)->D +ESTROY called (current pid: 26678, disconnect_by_pid: ) #26678 1366047614.00000 disconnect: Net::SFTP::Foreign=HASH(0x1faa380) +->disconnect called (ssh pid: 26679) #26678 1366047614.00000 _conn_lost: _conn_lost #26678 1366047614.00000 _set_status: _set_status code: 7, str: Connect +ion lost #26678 1366047614.00000 _set_error: _set_err code: 37, str: Connection + to remote server is broken debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK Transferred: sent 2288, received 1840 bytes, in 0.4 seconds Bytes per second: sent 5432.6, received 4368.8 debug1: Exit status 0 0-bash-4.1$
        remote end (bank) is tight-lipped about their setup

        The remote software version is the first thing you get when the SSH handshake starts. Just telnet to the remote host SSH port and you will see which software they are running. Running ssh with -vvv also gives you that information.

        Here's the result of a dry-run (no files) using debug

        This is useless, unless you show us the debugging output of some script where the problem actually happens, we will not be able to help you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1028531]
Approved by salva
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-03-28 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found