Rudá G.
2013-05-08 14:32:30 UTC
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 ***@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|
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 <Errno::EPIPE>
What am I doing wrong?
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 ***@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|
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 <Errno::EPIPE>
What am I doing wrong?
--
Posted via http://www.ruby-forum.com/.
Posted via http://www.ruby-forum.com/.