in reply to Net::SFTP::Foreign Password Authentication Hangs

It seems the password is not being accepted by the remote server.

The debugging output shows that the script hangs because the remote server accepts both password and keyboard-interactive authentication, a case where Net::SFTP::Foreign can't handle correctly failed password authentication.

A possible workaround is to force the authentication method to be either password or keyboard-interactive, for instance:

my $sftp = Net::SFTP::Foreign->new(..., more => [-o => 'PreferredAuthentica +tions=keyboard-interactive']);

Another possibility is to connect to the remote host via Net::OpenSSH which has a more sophisticated login algorithm, able to detect errors that Net::SFTP::Foreign doesn't:

my $ssh = Net::OpenSSH->new(...); my $sftp = $ssh->sftp;