Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Net::SSH::Perl operates in two modes:
  • batch mode
  • interactive mode

Interactive mode is off by default and must be turned on explicitly:

my $ssh = Net::SSH::Perl->new($ssh_box, interactive => 1);

Passwords and passphrases are read only in interactive mode, and always from the tty. In batch mode, all passwords are ignored.

Thus batch mode works only with public/private key pairs (rsa or dsa mode), which is IMHO The Right Thing. Storing passwords as plaintext in config files or scripts is unwise at it's best.

The documentation of Net::SSH::Perl is misleading on this behalf, as the method

$ssh->login($user, $pass);

will never work - by design!

Searching a bit further, I found the following in Net::SSH::Perl::Auth::KeyboardInt:

The authenticate method will enter into a dialog with the server. For keyboard-interactive authentication, this entails sending a request to authenticate the user using this form of authentication, then waiting for any number of prompts for authentication. These prompts are then presented to the user, who enters his/her responses; the responses are then sent back to the server, which either allows or denies the user's credentials.

The fact that this authentication method requires responses to interactive prompts requires that you only use this method in an interactive SSH connection.

Net::SSH::Perl appearently supports - besides user/password pairs - also challenge/response authentication methods; the authentication can involve multiple methods with would not fit into a simple user/pass schema.

I recall that this question is asked often; the manual page of Net::SSH::Perl is outdated and inaccurate and should be fixed. But it has a link for reporting bugs ;-)

<update>

If Net::SSH::Perl operates in batch mode, it disables the keyboard-interactive authentication method. You can verify this by commenting out line 116 of $perllib/Net/SSH/AuthMgr.pm:

# in sub auth_failure: for my $meth ( split /,/, $authlist ) { ... # next unless $auth->enabled; # <-- line 116 in v1.29 ... }

If you run your code with this modification, keyboard-interactive is tried in batch mode as well, and you are prompted for a password - the password you supplied to $ssh->login(); is just ignored.

</update>

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to Re: Is Net::SSH::Perl broken for login via explicit user/password? by shmem
in thread Is Net::SSH::Perl broken for login via explicit user/password? by tphyahoo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-26 05:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found