Perl SSH2 not working. Double login required.

Discussion in 'Perl Misc' started by piotr.snarski, Jun 10, 2014.

  1. Hi Guys,

    I'm trying to log into network device using SSH. Below code works perfectlyfor CISCO devices and others. However, to log into a PacketShaper device I'm prompted to insert login twice and in that case below code it not working. Using putty I'm getting such prompts:

    login as: #here I just hit eneter
    login: # actual username
    passowrd: #pass

    Do you have any ideas how to force it to work with double login prompts?

    #!/usr/bin/perl -w
    use strict;
    use Net::SSH2;

    my $ssh2 = Net::SSH2->new();
    $ssh2->connect("host") or die "Unable to connect host [email protected] \n";
    my $chan = $ssh2->channel();
    my $buflen = 10000;
    my $buf1 = '0' x $buflen;
    $chan->read($buf1, $buflen);
    print "BUF1:\n", $buf1,"\n";
    piotr.snarski, Jun 10, 2014
    1. Advertisements

  2. I know 'login as' as putty "before login" prompt and it can be used to
    enter a username. The 'system login prompt' than shouldn't appear
    Rainer Weikusat, Jun 10, 2014
    1. Advertisements

  3. Thanks for that.

    The thing is I'd like to code it with perl somehow.. I mean login to PacketShaper automatically... Is anybody aware how to rebuild the script and achieve the goal ?
    piotr.snarski, Jun 11, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.