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

Hello wise Monks

I have an issue with the usage of the package Net-SFTP-Foreign

The error message says:

SSH slave exited unexpectedly with error code 255

The script runs on a Ubuntu server. The sftp connection is manually tested from my PC with FileZilla. I try to establish the connection as follows:

$_sftp = Net::SFTP::Foreign->new( host => $ftpuser->{ server }, user => $ftpuser->{ benutzer }, password => $ftpuser->{ pass }, more => [qw(-o 'StrictHostKeyChecking=no')], #~ port => $ftpuser->{ port }, # soll bei SFTP immer 22 + sein );

I would be glad about any hint.

Thanks in advance, Thomas

Replies are listed 'Best First'.
Re: Net-SFTP-Foreign: SSH slave exited unexpectedly with error code 255
by salva (Canon) on Apr 08, 2015 at 10:07 UTC
    Enable debugging:
    $Net::SFTP::Foreign::debug = -1;
    And post the output

      Hello Salva,

      I have written a standalone test-script, which is independent from our web-application. The output is as follows:

      Content-type: text/html <h2>FtpSimple--sftp: 1.77</h2> #15404 1428578082.00000 new: This is Net::SFTP::Foreign 1.77 #15404 1428578082.00000 new: Loaded from /usr/local/share/perl/5.10.1/ +Net/SFTP/Foreign.pm #15404 1428578082.00000 new: Running on Perl v5.10.1 for linux #15404 1428578082.00000 new: debug set to -1 #15404 1428578082.00000 new: ~0 is 18446744073709551615 #15404 1428578082.00000 new: Using backend Net::SFTP::Foreign::Backend +::Unix 1.76_03 #15404 1428578082.00000 _init_transport: ssh cmd: ssh -o NumberOfPassw +ordPrompts=1 -o PreferredAuthentications=keyboard-interactive,passwor +d -l innosystems -o 'StrictHostKeyChecking=no' 00.000.00.00 -s sftp #15404 1428578082.00000 _init_transport: starting password authenticat +ion #15404 1428578082.00000 _init_transport: waiting for data from the pty + to become available command-line: line 0: Bad configuration option: 'StrictHostKeyChecking #15404 1428578083.00000 _conn_lost: _conn_lost #15404 1428578083.00000 _set_status: _set_status code: 6, str: No conn +ection #15404 1428578083.00000 _set_error: _set_err code: 37, str: SSH slave +exited unexpectedly with error code 255 #15404 1428578083.00000 _rel2abs: '/home/innosystems/in/doppelt-neu.tx +t' --> '/home/innosystems/in/doppelt-neu.txt' #15404 1428578083.00000 put: local file size is 555 #15404 1428578083.00000 _rel2abs: '/home/innosystems/in/doppelt-neu.tx +t' --> '/home/innosystems/in/doppelt-neu.txt' #15404 1428578083.00000 _queue_msg: queueing msg len: 57, code:3, id:0 + ... [1] 00 00 00 39 03 00 00 00 00 00 00 00 24 2f 68 6f 6d 65 2f 69 6e 6e 6f 7 +3 79 73 74 65 6d 73 2f 69 | ...9........$/home/innosystems/i 6e 2f 64 6f 70 70 65 6c 74 2d 6e 65 75 2e 74 78 74 00 00 00 1a 00 00 0 +0 04 00 00 01 a4 | n/doppelt-neu.txt............ #15404 1428578083.00000 _get_msg: waiting for message... [1] #15404 1428578083.00000 _do_io: _do_io connected: 0 #15404 1428578083.00000 _conn_lost: _conn_lost #15404 1428578083.00000 _set_status: _set_status code: 7, str: Connect +ion lost #15404 1428578083.00000 open: open failed: Connection lost #15404 1428578083.00000 DESTROY: Net::SFTP::Foreign=HASH(0x28be890)->D +ESTROY called (current pid: 15404, disconnect_by_pid: ) #15404 1428578083.00000 disconnect: Net::SFTP::Foreign=HASH(0x28be890) +->disconnect called (ssh pid: ) #15404 1428578083.00000 _conn_lost: _conn_lost
        Oh, wait!

        The problem is that you have a pair of extra quotes for the more options. It should be as follows:

        more => [qw(-o StrictHostKeyChecking=no)]
        For some reason the ssh client doesn't like the StrictHostKeyChecking option.

        Which one are you using?

        What do you get when you run ssh -V at the terminal. In case you don't have terminal access, add the following line to your script:

        system "ssh -V 1>&2";

      Hello Salva,
      I guess, the right position for that is there, isn't it?

      use Net::SFTP::Foreign; $Net::SFTP::Foreign::debug = -1; . . $_sftp = Net::SFTP::Foreign->new( .. );
        Yes, that should work.