# Net::Telnet can't send password message

**URL:** <https://www.ruby-forum.com/t/net-telnet-cant-send-password-message/175207>\
**Category:** Ruby\
**Created:** [September 9, 2009, 6:14pm UTC](https://www.ruby-forum.com/t/net-telnet-cant-send-password-message/175207 "2009-09-09T18:14:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![born\_in\_USSR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/2bfe46/32.png) [@born\_in\_USSR](https://www.ruby-forum.com/u/born_in_USSR)\
**Post date:** [September 9, 2009, 6:14pm UTC](https://www.ruby-forum.com/t/net-telnet-cant-send-password-message/175207/1 "2009-09-09T18:14:22Z")

</div>

```auto
      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

```auto
      ...
      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?

---

<div class="post-metadata">

**Author:** ![born\_in\_USSR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/2bfe46/32.png) [@born\_in\_USSR](https://www.ruby-forum.com/u/born_in_USSR)\
**Post date:** [September 9, 2009, 9:06pm UTC](https://www.ruby-forum.com/t/net-telnet-cant-send-password-message/175207/2 "2009-09-09T21:06:09Z")

</div>

born in USSR wrote:

> ```auto
> 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
> 
> ```auto
> ...
> > 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.

---

<div class="post-metadata">

**Author:** ![born\_in\_USSR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/2bfe46/32.png) [@born\_in\_USSR](https://www.ruby-forum.com/u/born_in_USSR)\
**Post date:** [September 9, 2009, 11:31pm UTC](https://www.ruby-forum.com/t/net-telnet-cant-send-password-message/175207/3 "2009-09-09T23:31:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![born\_in\_USSR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/2bfe46/32.png) [@born\_in\_USSR](https://www.ruby-forum.com/u/born_in_USSR)\
**Post date:** [September 9, 2009, 11:41pm UTC](https://www.ruby-forum.com/t/net-telnet-cant-send-password-message/175207/4 "2009-09-09T23:41:38Z")

</div>

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](http://linuxproblem.org/art_9.html)

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

-r.

---

<div class="post-metadata">

**Author:** ![born\_in\_USSR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/2bfe46/32.png) [@born\_in\_USSR](https://www.ruby-forum.com/u/born_in_USSR)\
**Post date:** [September 10, 2009, 3:31am UTC](https://www.ruby-forum.com/t/net-telnet-cant-send-password-message/175207/5 "2009-09-10T03:31:00Z")

</div>

Rodrigo B. wrote:

> Then you need this:  
> [SSH login without password](http://linuxproblem.org/art_9.html)
> 
> Ssh prevents you to send the password in “an automatic way”.
> 
> -r.

thank’s
