Here is the code and the output :

Code :

use Net::OpenSSH::Compat::SSH2 qw(:supplant); use Net::SSH2; $Net::OpenSSH::debug=-1; my $ip = 'xxx'; my $port = 22; my $username = 'user1'; my $password = 'user1'; my $ssh2 = Net::SSH2->new(); $ssh2->connect($ip,$port) or die $!; my $res = $ssh2->auth(username => $username, password => $password,) or die "$!",$ssh2->error +; print "result is $res\n";

Output :

> perl compatssh2.pl # ctl_path: /home/smokes/.libnet-openssh-perl/regression-192.168.2.-11 +175-417065, ctl_dir: /home/smokes/.libnet-openssh-perl/ # _is_secure_path(dir: /home/smokes/.libnet-openssh-perl, file mode: 1 +6832, file uid: 1003, euid: 1003 # _is_secure_path(dir: /home/smokes, file mode: 16877, file uid: 1003, + euid: 1003 # set_error(0 - 0) # call args: ['ssh','-o','ServerAliveInterval=30','-x2MN','-o','Number +OfPasswordPrompts=1','-o','PreferredAuthentications=keyboard-interact +ive,password','-S','/home/smokes/.libnet-openssh-perl/user1-192.168.2 +.-11175-417065','-l','user1','-p',22,'192.168.2.215','--'] # file object not yet found at /home/smokes/.libnet-openssh-perl/regre +ssion-192.168.2.-11175-417065 # file object not yet found at /home/smokes/.libnet-openssh-perl/regre +ssion-192.168.2.-11175-417065 # file object not yet found at /home/smokes/.libnet-openssh-perl/regre +ssion-192.168.2.-11175-417065 # file object not yet found at /home/smokes/.libnet-openssh-perl/regre +ssion-192.168.2.-11175-417065 # file object not yet found at /home/smokes/.libnet-openssh-perl/regre +ssion-192.168.2.-11175-417065 # file object not yet found at /home/smokes/.libnet-openssh-perl/regre +ssion-192.168.2.-11175-417065 # tracer attached, ssh pid: 11177, tracer pid: 11178 # set_error(1 - unable to establish master SSH connection: the authent +icity of the target host can't be established, the remote host public + key is probably not present on the '~/.ssh/known_hosts' file) # _kill_master: 11177 # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 0, rc: # killing master with signal TERM # waitpid(master: 11177) => pid: 0, rc: # waitpid(master: 11177) => pid: 11177, rc: Interrupted system call # DESTROY(Net::OpenSSH=HASH(0xdb75b0), pid: <undef>) Interrupted system callLIBSSH2_ERROR_SOCKET_DISCONNECTunable to establ +ish master SSH connection: the authenticity of the target host can't +be established, the remote host public key is probably not present on + the '~/.ssh/known_hosts' file at compatssh2.pl line 13.

In reply to Re^2: Net::OpenSSH::Compat::SSH2 auth_password fails by madhurikl
in thread Net::OpenSSH::Compat::SSH2 auth_password fails by madhurikl

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.