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
...
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?
born in USSR wrote:
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
...
> 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.
born in USSR wrote:
Rodrigo B. 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.