Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Net::SFTP::Recursive problem with ssh_args => [use_pty => 0 ]

by gman (Friar)
on Mar 02, 2011 at 19:42 UTC ( [id://891081]=perlquestion: print w/replies, xml ) Need Help??

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

Hello all,

I have been attempting to use Net::SFTP::Recursive, unfortunately the system I am connecting to appears to have a broken implementation of ssh. With debug:

host.fqdn.tld: Trying password authentication. host.fqdn.tld: Login completed, opening dummy shell channel. host.fqdn.tld: channel 0: new [client-session] host.fqdn.tld: Requesting channel_open for channel 0. host.fqdn.tld: channel 0: open confirm rwindow 32768 rmax 16384 host.fqdn.tld: channel 1: new [client-session] host.fqdn.tld: Requesting channel_open for channel 1. host.fqdn.tld: Channel open failure: 1: reason 4: Server supports one +session per SSH client host.fqdn.tld: sftp: Sending SSH2_FXP_INIT Connection closed at recurse_sftp.pl line 37

I did read this post 688247 but again, if I am reading the debug correctly it is still trying to open a second channel or am I reading the debug incorrectly?

Here is my code, pretty much right from the docs

use Net::SFTP::Recursive; my $host = 'x.x.x.x'; my %cfg = ( user=>'user', password=>'passwd', ssh_args => [ protocol => "2 1", use_pty => 0 ], debug => 'true' ); my $sftp = Net::SFTP::Recursive->new($host,%cfg);
Thanks in advance!

Replies are listed 'Best First'.
Re: Net::SFTP::Recursive problem with ssh_args => [use_pty => 0 ]
by salva (Canon) on Mar 02, 2011 at 20:44 UTC
      Thank you, forgot about Net::SFTP::Foreign ++
Re: Net::SFTP::Recursive problem with ssh_args => [use_pty => 0 ]
by Khen1950fx (Canon) on Mar 03, 2011 at 02:33 UTC
    I noticed a couple of errors. Looking at your debug output:

    host.fqdn.tld: sftp: Sending SSH2_FXP_INIT
    That's telling you that Net::SFTP, which underlies Net::SFTP::Recursive, only supports SSH2 and not SSH1. So takeout the protocol => '2 1' because it isn't necessary.

    Second, I'd change debug => 'true' to debug => 1 because it's easier to read. Then your script should start something like this:

    #!/usr/bin/perl use strict; use warnings; use Net::SFTP::Recursive; use Data::Dumper; my $host = '127.0.0.1'; my %cfg = ( user => 'user', password => 'password', debug => 1, ); my $sftp = Net::SFTP::Recursive->new($host, %cfg);
    From what I can see, I think that your server expects SSH1, but it's not getting it:-).
      That's telling you that Net::SFTP, which underlies Net::SFTP::Recursive, only supports SSH2 and not SSH1

      Not really!

      Net::SFTP implements version 3 of the protocol, that's the one supported by most servers regardless of its supported SSH protocol version.

      What happens is that the underlaying buggy Net::SSH::Perl is trying to open two channels inside the same SSH connection but the server only supports one channel per connection:

      host.fqdn.tld: channel 0: new [client-session] host.fqdn.tld: Requesting channel_open for channel 0. host.fqdn.tld: channel 0: open confirm rwindow 32768 rmax 16384 host.fqdn.tld: channel 1: new [client-session] host.fqdn.tld: Requesting channel_open for channel 1. host.fqdn.tld: Channel open failure: 1: reason 4: Server supports one +session per SSH client

      Then, Net::SFTP does not check that the channel was successfully open, tries to send the INIT command anyway and fails.

      For comparison, opening a SFTP connection with OpenSSH:

      $ ssh -v localhost -s sftp ... debug1: Authentication succeeded (publickey). debug1: channel 0: new [client-session] debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LC_MESSAGES = en_AG.utf8 debug1: Sending env LANG = en_US.UTF-8 debug1: Sending subsystem: sftp
      It just opens a channel and uses it for SFTP.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found