Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Does Net::SFTP::Foreign support identity file and user password?

by Tanoti (Initiate)
on Sep 24, 2012 at 10:13 UTC ( #995340=perlquestion: print w/replies, xml ) Need Help??
Tanoti has asked for the wisdom of the Perl Monks concerning the following question:

We have customer that requires us to connect to their SFTP server using an identify file and a password (not a key's passphrase, we are aware of the difference). We can do this manually but not when using Net::SFTP::Foreign where we get permission denied. Before we beat our heads against the problem too much, I wondered if this scenario is supported by the module at all?
  • Comment on Does Net::SFTP::Foreign support identity file and user password?

Replies are listed 'Best First'.
Re: Does Net::SFTP::Foreign support identity file and user password?
by salva (Abbot) on Sep 24, 2012 at 15:05 UTC
    my $sftp = Net::SFTP::Foreign->new($host, user => $user, password => $password, more => [-o => 'PreferredAuthentica +tions=publickey,password,keyboard-interactive']);
    This is mostly a hack but your configuration is quite unusual (you are the second person that asks for it) so I (the module author) never bothered adding support for it... maybe it is time to reconsider that!
      Sadly that did not work. We can see the password being asked for and sent but the remote server is then denying access:

      # looking for user/password prompt # matching against (?i-xsm:(user|name|login)?[:?]\s*$) # sending password # checking timeout, max: 120, ellapsed: 0.291105031967163 # waiting for data from the pty to become available # 2 bytes readed from pty: debug3: packet_send2: adding 40 (len 82 padlen 6 extra_pad 64) debug2: we sent a password packet, wait for reply 0d 0a + | .. # looking for password ok # password authentication done Authenticated with partial success. debug1: Authentications that can continue: password,publickey debug2: we did not send a packet, disable method debug1: No more authentication methods to try. Permission denied (password,publickey).

      We will try and get the remote server ssh configuration from the customer in case they are using some strange settings so we can duplicate on our systems.

      Thank you for you help and please do include this scenario as an option for the module as it appears to be a security policy in the financial sector.

        Maybe you have to change the order of the PreferredAuthentications tokens to suit the server:
        my $sftp = Net::SFTP::Foreign->new($host, user => $user, password => $password, more => [-o => 'PreferredAuthentica +tions=password,keyboard-interactive,publickey']);

        Could you include the full debugging output from the ssh binary when called from Net::SFTP::Foreign and also when you do it by hand to see what is being done differently?

Re: Does Net::SFTP::Foreign support identity file and user password?
by Anonymous Monk on Sep 24, 2012 at 10:41 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://995340]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2017-11-24 00:12 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (343 votes). Check out past polls.