From: Cliff Rosson Date: 2013-05-09T00:29:26+09:00 Subject: Re: Connect to a switch with SSH --089e01537ba4f3f15904dc368600 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Why not just use net/ssh/telnet? I provided a link for you in the other thread. On Wed, May 8, 2013 at 7:32 AM, Rud=E1 G. wrote: > I need connect to a Cisco Switch with SSH and Ruby. The main problem is > the authentication which is different. I must enter 'login as', 'User > Name' and 'Password'. The 'login as' can be any value, usually I just > press enter (empty value). > > My first try was with Net::SSH but it was impossible to authenticate. I > don't know if I did something wrong but I had always the > Net::SSH::AuthenticationFailed error then I gave up. > > Now I'm trying with Plink (a command-line interface to the PuTTY back > ends). On the shell I do like this: > > > plink -ssh user@XX.XX.XXX.XX > User Name: > Password: > Commands... > > > Now I need call and interact with Plink on Ruby. My last try was this: > > IO.popen "plink -ssh user@#{CISCO}", 'w+' do |io| > io.each do |line| > puts line > if line.include?('User Name') > io.write(USER) > elsif line.include?('Password') > io.write(PASS) > end > end > end > > and the error was: > 'write': Broken pipe > > What am I doing wrong? > > -- > Posted via http://www.ruby-forum.com/. > > --=20 vizualize.me/cliffrosson --089e01537ba4f3f15904dc368600 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Why not just use net/ssh/telnet? I provided a link for you= in the other thread.


On Wed, May 8, 2013 at 7:32 AM, Rud=E1 G. &= lt;lists@ruby-for= um.com> wrote:
I need connect to a Cisco Switch with SSH an= d Ruby. The main problem is
the authentication which is different. I must enter 'login as', = 9;User
Name' and 'Password'. The 'login as' can be any value, = usually I just
press enter (empty value).

My first try was with Net::SSH but it was impossible to authenticate. I
don't know if I did something wrong but I had always the
Net::SSH::AuthenticationFailed error then I gave up.

Now I'm trying with Plink (a command-line interface to the PuTTY back ends). On the shell I do like this:


plink -ssh user@XX.XX.XXX.XX
User Name: <enter user here>
Password: <enter pass here>
Commands...


Now I need call and interact with Plink on Ruby. My last try was this:

IO.popen "plink -ssh user@#{CISCO}", 'w+' do |io|
=A0 io.each do |line|
=A0 =A0 puts line
=A0 if line.include?('User Name')
=A0 =A0 io.write(USER)
=A0 elsif line.include?('Password')
=A0 =A0 io.write(PASS)
=A0 end
=A0 end
end

and the error was:
'write': Broken pipe <Errno::EPIPE>

What am I doing wrong?

--
Posted via http://= www.ruby-forum.com/.




--
--089e01537ba4f3f15904dc368600--