Skip Menu |

This queue is for tickets about the Net-SFTP-Foreign CPAN distribution.

Report information
The Basics
Id: 82145
Status: resolved
Priority: 0/
Queue: Net-SFTP-Foreign

People
Owner: Nobody in particular
Requestors: aaroncouts [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.73
Fixed in: (no value)



Subject: Connection hangs for certain servers when password is incorrect
I found a server that is not compatible with the '-o NumberOfPasswordPrompts=1' option that Net::SFTP::Foreign passes on to sftp: $ sftp -o NumberOfPasswordPrompts=1 user@___.com Connecting to ___... This System Is For Authorized Users Only. Password Authentication Password: (wrong password) user@___.com's password: Normally, with this option, sftp will disconnect after a single bad password attempt. This server sends a second, slightly different, password request. Net::SFTP::Foreign doesn't know what to do with the second password request, and it hangs. My quick fix was to add an extra line feed when the password is sent initially (line 314 of Foreign/Backup/Unix.pm in version 1.73). print $pty "$pass\n\n"; If the password is incorrect, the extra line feed gets us past the second password prompt. If the login is correct, it posts a harmless linefeed to the sftp interface. This is a hack, but I figured I would mess things up if I did another sysread from $pty.
From: aaroncouts [...] gmail.com
Show quoted text
> print $pty "$pass\n\n";
This fix didn't actually work. I stepped through the code but wasn't able to find the point where the second password request was read into the buffer.
Subject: Re: [rt.cpan.org #82145] Connection hangs for certain servers when password is incorrect
Date: Sat, 5 Jan 2013 07:13:29 -0800 (PST)
To: "bug-Net-SFTP-Foreign [...] rt.cpan.org" <bug-Net-SFTP-Foreign [...] rt.cpan.org>
From: Salvador Fandino <sfandino [...] yahoo.com>
Show quoted text
----- Original Message -----
> From: Aaron Couts via RT <bug-Net-SFTP-Foreign@rt.cpan.org> > To: > Cc: > Sent: Thursday, December 20, 2012 10:37 PM > Subject: [rt.cpan.org #82145] Connection hangs for certain servers when password is incorrect > >T hu Dec 20 16:37:34 2012: Request 82145 was acted upon. > Transaction: Ticket created by aaroncouts1 >       Queue: Net-SFTP-Foreign >     Subject: Connection hangs for certain servers when password is incorrect >   Broken in: 1.73 >     Severity: Normal >       Owner: Nobody >   Requestors: aaroncouts@gmail.com >       Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=82145 > > > > I found a server that is not compatible with the '-o > NumberOfPasswordPrompts=1' option that Net::SFTP::Foreign passes on to > sftp: > > $ sftp -o NumberOfPasswordPrompts=1 user@___.com > Connecting to ___... > This System Is For Authorized Users Only. > Password Authentication > Password: (wrong password) > user@___.com's password: > > Normally, with this option, sftp will disconnect after a single bad > password attempt.  This server sends a second, slightly different, > password request.  Net::SFTP::Foreign doesn't know what to do with the > second password request, and it hangs.
Maybe the server accepts both keyboard-interactive and password authentication. Try forcing just one as follows:   $sftp = Net::SFTP::Foreign->new($host, user => $user, password => $password,                                                     more => [-o => 'PreferredAuthentications=keyboard-interactive']);
From: aaroncouts [...] gmail.com
On Sat Jan 05 10:13:38 2013, sfandino@yahoo.com wrote: Show quoted text
> ----- Original Message -----
> > From: Aaron Couts via RT <bug-Net-SFTP-Foreign@rt.cpan.org> > > To: > > Cc: > > Sent: Thursday, December 20, 2012 10:37 PM > > Subject: [rt.cpan.org #82145] Connection hangs for certain servers
> when password is incorrect
> > > >T hu Dec 20 16:37:34 2012: Request 82145 was acted upon. > > Transaction: Ticket created by aaroncouts1 > >       Queue: Net-SFTP-Foreign > >     Subject: Connection hangs for certain servers when password is
> incorrect
> >   Broken in: 1.73 > >     Severity: Normal > >       Owner: Nobody > >   Requestors: aaroncouts@gmail.com > >       Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=82145 > > > > > > > I found a server that is not compatible with the '-o > > NumberOfPasswordPrompts=1' option that Net::SFTP::Foreign passes on
> to
> > sftp: > > > > $ sftp -o NumberOfPasswordPrompts=1 user@___.com > > Connecting to ___... > > This System Is For Authorized Users Only. > > Password Authentication > > Password: (wrong password) > > user@___.com's password: > > > > Normally, with this option, sftp will disconnect after a single bad > > password attempt.  This server sends a second, slightly different, > > password request.  Net::SFTP::Foreign doesn't know what to do with
> the
> > second password request, and it hangs.
> > Maybe the server accepts both keyboard-interactive and password > authentication. > > Try forcing just one as follows: > >   $sftp = Net::SFTP::Foreign->new($host, user => $user, password => > $password, >                                                     more => [-o => > 'PreferredAuthentications=keyboard-interactive']);
Finally got an opportunity to test this. Your suggestion worked! Thanks!