Net::Telnet can't send password message

B

born in USSR

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                                      # [email protected]'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
# '[email protected]'s password:'
# but there were was nothing
tserv.puts user_paswd
...
but it doesn't work too.

how can i input password for ssh?
 
R

Rodrigo Bermejo

born said:
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                                      # [email protected]'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
# '[email protected]'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.
 
B

born in USSR

Rodrigo said:
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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,692
Latest member
JenniferTi

Latest Threads

Top