Net::SSH::Perl dies during logon only when username is entered in stdin

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default Net::SSH::Perl dies during logon only when username is entered in stdin

    Hi, could anyone please help me with this?

    I am writing a script that would ssh to a remote computer and execute
    commands,
    but mine does not get past the logon. Here is my code:

    my %args;
    $args{protocol} = '2';
    $args{debug} = 1;

    my @hosts = ("127.0.0.1");

    #my $user = "testuser";
    my $oldpass = 'xxx';

    print "Please enter your username: ";
    my $user = <STDIN>;
    chomp $user;

    foreach my $host (@hosts)
    {
    my $ssh = Net::SSH::Perl->new($host, %args);

    $ssh->login($username5, $oldpass);
    ....}

    This sript dies, with these debug statements:
    "acs-114-24.barnard.columbia.edu: Sent key-exchange init (KEXINIT),
    wait response.
    acs-114-24.barnard.columbia.edu: Algorithms, c->s: 3des-cbc hmac-sha1
    none
    acs-114-24.barnard.columbia.edu: Algorithms, s->c: 3des-cbc hmac-sha1
    none
    acs-114-24.barnard.columbia.edu: Entering Diffie-Hellman Group 1 key
    exchange.
    acs-114-24.barnard.columbia.edu: Sent DH public key, waiting for
    reply.
    acs-114-24.barnard.columbia.edu: Received host key, type 'ssh-dss'.
    acs-114-24.barnard.columbia.edu: Host '127.0.0.1' is known and matches
    the host key.
    acs-114-24.barnard.columbia.edu: Computing shared secret key.
    acs-114-24.barnard.columbia.edu: Verifying server signature.
    acs-114-24.barnard.columbia.edu: Waiting for NEWKEYS message.
    acs-114-24.barnard.columbia.edu: Enabling incoming
    encryption/MAC/compression.
    acs-114-24.barnard.columbia.edu: Send NEWKEYS, enable outgoing
    encryption/MAC/compression.
    acs-114-24.barnard.columbia.edu: Sending request for
    user-authentication service.
    acs-114-24.barnard.columbia.edu: Service accepted: ssh-userauth.
    acs-114-24.barnard.columbia.edu: Trying empty user-authentication
    request.
    input must be 8 bytes long at
    /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Crypt/DES.pm
    line 59."

    However, if instead of prompting the user to enter the username, I
    simply do
    $user = "testuser"
    then there is no problem and I can login just fine.

    The problem probably lies with input from stdin not being exactly the
    same as 'testuser', but I print the input out just before sending it
    to login, and it prints 'testuser'. Does anyone have any ideas that
    may help me?

    Thank you so much,
    Michael
    new bee Guest

  2. Similar Questions and Discussions

    1. Show username after login | Example: Welcome "USERNAME"to your Backoffice.
      hi. I've created a backoffice in php, and i would like to apply on the page the name of the user who has just logged in. Example: Welcome...
    2. 'unpipe' STDIN
      Hi - I have a perl 'filter' script that relies on piped input from STDIN, i.e.: find /etc/ | ./myfilter.pl etc... I have a need to interact...
    3. fflush stdin
      hello all, Quick question How do I flush stdin. I am writing an interactive console based script And I want that all inputs received before my...
    4. <STDIN>
      In my script iam using the following line.. ..... where the user has to keyin either of the options 1)"Change_Request", 2)"call_req" 3)"Both" ...
    5. STDIN
      use Time::Local; use FileHandle; my @month_list = qw/ January February March April May June July August September October November December /;...
  3. #2

    Default Re: Net::SSH::Perl dies during logon only when username is enteredin stdin

    new bee wrote:
    > Hi, could anyone please help me with this?
    >
    > I am writing a script that would ssh to a remote computer and execute
    > commands,
    > but mine does not get past the logon. Here is my code:
    >
    > my %args;
    > $args{protocol} = '2';
    > $args{debug} = 1;
    >
    > my @hosts = ("127.0.0.1");
    >
    > #my $user = "testuser";
    > my $oldpass = 'xxx';
    >
    > print "Please enter your username: ";
    > my $user = <STDIN>;
    > chomp $user;
    >
    > foreach my $host (@hosts)
    > {
    > my $ssh = Net::SSH::Perl->new($host, %args);
    >
    > $ssh->login($username5, $oldpass);
    Where does $username5 come from? Shouldn't it have been $user?
    Jim Keenan Guest

  4. #3

    Default Re: Net::SSH::Perl dies during logon only when username is enteredin stdin

    see lots of comments inline, all the way down to the bottom.

    new bee wrote:
    >Hi, could anyone please help me with this?
    >
    >I am writing a script that would ssh to a remote computer and execute
    >commands,
    >but mine does not get past the logon. Here is my code:
    >
    use warnings;
    use strict;

    # the above two lines will tell you what the problem is. use them in
    all of your programs.
    >
    >my %args;
    >$args{protocol} = '2';
    >$args{debug} = 1;
    >
    >my @hosts = ("127.0.0.1");
    >
    >#my $user = "testuser";
    >my $oldpass = 'xxx';
    >
    >print "Please enter your username: ";
    >my $user = <STDIN>;
    >chomp $user;
    >
    >foreach my $host (@hosts)
    >{
    > my $ssh = Net::SSH::Perl->new($host, %args);
    >
    > $ssh->login($username5, $oldpass);
    >
    an error would be reported here if you had used: "use strict".
    >...}
    >
    >This sript dies, with these debug statements:
    >"acs-114-24.barnard.columbia.edu: Sent key-exchange init (KEXINIT),
    >wait response.
    >acs-114-24.barnard.columbia.edu: Algorithms, c->s: 3des-cbc hmac-sha1
    >none
    >acs-114-24.barnard.columbia.edu: Algorithms, s->c: 3des-cbc hmac-sha1
    >none
    >acs-114-24.barnard.columbia.edu: Entering Diffie-Hellman Group 1 key
    >exchange.
    >acs-114-24.barnard.columbia.edu: Sent DH public key, waiting for
    >reply.
    >acs-114-24.barnard.columbia.edu: Received host key, type 'ssh-dss'.
    >acs-114-24.barnard.columbia.edu: Host '127.0.0.1' is known and matches
    >the host key.
    >acs-114-24.barnard.columbia.edu: Computing shared secret key.
    >acs-114-24.barnard.columbia.edu: Verifying server signature.
    >acs-114-24.barnard.columbia.edu: Waiting for NEWKEYS message.
    >acs-114-24.barnard.columbia.edu: Enabling incoming
    >encryption/MAC/compression.
    >acs-114-24.barnard.columbia.edu: Send NEWKEYS, enable outgoing
    >encryption/MAC/compression.
    >acs-114-24.barnard.columbia.edu: Sending request for
    >user-authentication service.
    >acs-114-24.barnard.columbia.edu: Service accepted: ssh-userauth.
    >acs-114-24.barnard.columbia.edu: Trying empty user-authentication
    >request.
    >
    here is an error message that further gives a hint about what the
    problem is.
    >input must be 8 bytes long at
    >/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Crypt/DES.pm
    >line 59."
    >
    >
    --
    _____cliff_rayman_____cliff_@_rayman_._com_____

    ___cliff rayman___ Guest

  5. #4

    Default Re: Net::SSH::Perl dies during logon only when username is entered in stdin

    I ran into this a long time ago....I think it has something to do with the encoding of the text. You need to convert from one format to another -- Unicode has something to do with it. There's a Perl package somewhere that takes care of it.
    Keith Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139