Net::Telnet can't send password message

Discussion in 'Ruby' started by born in USSR, Sep 9, 2009.

  1. born in USSR

    born in USSR Guest

    Code:
    require "net/telnet"
    
    user_login='user1'
    user_paswd='xxxxxx'
    ssh_host='192.168.1.2'
    
    tserv = Net::Telnet::new("Host" => "192.168.1.5",
    "Timeout" => 10,
    "Prompt" => /[$%#>] \z/n)
    
    ans=tserv.login(user_login,user_paswd) # Successful authentication
    
    tserv.cmd('ssh -l #{user_login} #{ssh_host}')do |c| # on the
    screen:
    puts c.to_s                             # ssh -l user1
    192.168.1.2
    end                                      # user1@192.168.1.2's
    password:
    
    tserv.close
    
    i also tried
    Code:
    ...
    tserv.puts('ssh -l #{user_login} #{ssh_host}')
    puts tserv.gets  # assumed that on screen i'll see
    # 'user1@192.168.1.2's password:'
    # but there were was nothing
    tserv.puts user_paswd
    ...
    
    but it doesn't work too.

    how can i input password for ssh?
    --
    Posted via http://www.ruby-forum.com/.
    born in USSR, Sep 9, 2009
    #1
    1. Advertising

  2. born in USSR wrote:
    >
    Code:
    >       require "net/telnet"
    >
    >       user_login='user1'
    >       user_paswd='xxxxxx'
    >       ssh_host='192.168.1.2'
    >
    >       tserv = Net::Telnet::new("Host" => "192.168.1.5",
    >                                        "Timeout" => 10,
    >                               "Prompt" => /[$%#>] \z/n)
    >
    >       ans=tserv.login(user_login,user_paswd) # Successful authentication
    >
    >       tserv.cmd('ssh -l #{user_login} #{ssh_host}')do |c| # on the
    > screen:
    >        puts c.to_s                             # ssh -l user1
    > 192.168.1.2
    >       end                                      # user1@192.168.1.2's
    > password:
    >
    >       tserv.close
    > 
    >
    > i also tried
    >
    Code:
    >       ...
    >       tserv.puts('ssh -l #{user_login} #{ssh_host}')
    >       puts tserv.gets  # assumed that on screen i'll see
    >                        # 'user1@192.168.1.2's password:'
    >                        # but there were was nothing
    >       tserv.puts user_paswd
    >       ...
    >    
    > but it doesn't work too.
    >
    > how can i input password for ssh?

    Sanity check question:
    why not doing the ssh connection directly from the host you are doing
    the telnet (with net/ssh)?

    If there's not a key associated with your telnet machine it would be
    easier to connect directly using ssh

    -r.

    --
    Posted via http://www.ruby-forum.com/.
    Rodrigo Bermejo, Sep 9, 2009
    #2
    1. Advertising

  3. born in USSR

    born in USSR Guest

    Rodrigo Bermejo wrote:
    >
    > Sanity check question:
    > why not doing the ssh connection directly from the host you are doing
    > the telnet (with net/ssh)?
    >
    > If there's not a key associated with your telnet machine it would be
    > easier to connect directly using ssh
    >
    > -r.

    I know that it will be easy but
    i can't do differently, it's caused by other requirements to the
    program.
    --
    Posted via http://www.ruby-forum.com/.
    born in USSR, Sep 9, 2009
    #3
  4. born in USSR wrote:
    > Rodrigo Bermejo wrote:
    >>
    >> Sanity check question:
    >> why not doing the ssh connection directly from the host you are doing
    >> the telnet (with net/ssh)?
    >>
    >> If there's not a key associated with your telnet machine it would be
    >> easier to connect directly using ssh
    >>
    >> -r.

    > I know that it will be easy but
    > i can't do differently, it's caused by other requirements to the
    > program.


    Then you need this:
    http://linuxproblem.org/art_9.html


    Ssh prevents you to send the password in "an automatic way".

    -r.
    <born in Mexico>
    --
    Posted via http://www.ruby-forum.com/.
    Rodrigo Bermejo, Sep 9, 2009
    #4
  5. born in USSR

    born in USSR Guest

    born in USSR, Sep 10, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Isaacson
    Replies:
    5
    Views:
    593
    Default User
    Nov 5, 2004
  2. AAaron123
    Replies:
    2
    Views:
    2,090
    AAaron123
    Jan 16, 2009
  3. AAaron123
    Replies:
    1
    Views:
    1,310
    Oriane
    Jan 16, 2009
  4. Daniel Berger
    Replies:
    1
    Views:
    100
    Daniel Berger
    Jul 10, 2007
  5. Carcarius
    Replies:
    0
    Views:
    275
    Carcarius
    Dec 6, 2007
Loading...

Share This Page