Hi,
I am having trouble with the Net::SSH:start() function on one device,
but not another. During a DEBUG I receive a ‘channel_failure: 0’ error
resulting in the commands passed to my exec!() function not executing
on the remote host.
I AM able to execute the code below on a Cisco switch and router, but
receive errors when trying to execute similar code on a Cisco Wireless
LAN Controller (WLC).
#Works on a switch…
require ‘net/ssh’
output=""
Net::SSH.start(‘192.168.4.15’, ‘username’, :password => “Cisco”) do |
ssh|
output = ssh.exec!(“show interfaces status”)
end
#Fails on a WLC…
require ‘net/ssh’
output=""
Net::SSH.start(‘192.168.4.40’, ‘username’, :password => “Cisco”) do |
ssh|
output = ssh.exec!(“show ap summary”)
end
I think this may be due to how a WLC prompts for login credentials;
below is the sign on for a Cisco switch, followed by a WLC:
#Switch SSH sign on…
Username: username
Password: *****
SW1>
#WLC SSH sign on…
login as: username
Username: username
Password: *****
Notice the extra ‘login as:’ prompt on the WLC. Note that when using
PuTTy if you enter the hostname as ‘[email protected]’ as oppossed
to just ‘192.168.4.40’ the extra ‘login as:’ field gets auto-
populated.
Below is a most of the DEBUG from the WLC SSH sign on including the
‘channel_failure: 0’ error:
#Unneccessary lines above ommitted
C:\Apps\Cisco SSH>irb
irb(main):001:0> require ‘net/ssh’
=> true
irb(main):002:0> output=""
=> “”
irb(main):003:0> Net::SSH.start(‘192.168.4.40’, ‘username’, :password
=> “Cisco”, :verbose => Logger::DEBUG) do |ssh|
irb(main):004:1* output = ssh.exec!(“show ap summary”)
irb(main):005:1> end
D, [2008-05-08T20:40:05.041000 #3148] DEBUG –
net.ssh.transport.session[170ebf2]: establishing connection to
192.168.4.40:22
#omitted lines…
D, [2008-05-08T20:40:11.931000 #3148] DEBUG –
net.ssh.authentication.session[16fe4c8]: beginning authentication of
`username’
#omitted lines…
D, [2008-05-08T20:40:11.961000 #3148] DEBUG –
net.ssh.authentication.session[16fe4c8]: trying password
D, [2008-05-08T20:40:11.961000 #3148] DEBUG – tcpsocket[170ea12]:
queueing packet nr 5 type 50 len 60
D, [2008-05-08T20:40:11.961000 #3148] DEBUG – tcpsocket[170ea12]:
sent 84 bytes
D, [2008-05-08T20:40:11.971000 #3148] DEBUG – tcpsocket[170ea12]:
read 36 bytes
D, [2008-05-08T20:40:11.971000 #3148] DEBUG – tcpsocket[170ea12]:
received packet nr 5 type 52 len 12
D, [2008-05-08T20:40:11.981000 #3148] DEBUG –
net.ssh.authentication.methods.password[16fcff6]: password succeeded
D, [2008-05-08T20:40:11.981000 #3148] DEBUG – tcpsocket[170ea12]:
queueing packet nr 6 type 90 len 44
D, [2008-05-08T20:40:11.981000 #3148] DEBUG – tcpsocket[170ea12]:
sent 68 bytes
D, [2008-05-08T20:40:11.991000 #3148] DEBUG – tcpsocket[170ea12]:
read 52 bytes
D, [2008-05-08T20:40:12.001000 #3148] DEBUG – tcpsocket[170ea12]:
received packet nr 6 type 91 len 28
I, [2008-05-08T20:40:12.001000 #3148] INFO –
net.ssh.connection.session[16fc47a]: channel_open_confirmation:
0 0 0 32768
I, [2008-05-08T20:40:12.001000 #3148] INFO –
net.ssh.connection.channel[16fc376]: sending channel request “exec”
D, [2008-05-08T20:40:12.001000 #3148] DEBUG – tcpsocket[170ea12]:
queueing packet nr 7 type 98 len 44
D, [2008-05-08T20:40:12.001000 #3148] DEBUG – tcpsocket[170ea12]:
sent 68 bytes
D, [2008-05-08T20:40:12.011000 #3148] DEBUG – tcpsocket[170ea12]:
read 36 bytes
D, [2008-05-08T20:40:12.021000 #3148] DEBUG – tcpsocket[170ea12]:
received packet nr 7 type 100 len 12
I, [2008-05-08T20:40:12.021000 #3148] INFO –
net.ssh.connection.session[16fc47a]: channel_failure: 0
RuntimeError: could not execute command: “show ap summary”
from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/
connection/session.rb:294:in exec' from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/ connection/channel.rb:592:in
call’
from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/
connection/channel.rb:592:in do_failure' from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/ connection/session.rb:558:in
channel_failure’
from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/
connection/session.rb:428:in send' from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/ connection/session.rb:428:in
dispatch_incoming_packets’
from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/
connection/session.rb:185:in preprocess' from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/ connection/session.rb:169:in
process’
from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/
connection/session.rb:133:in loop' from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/ connection/session.rb:133:in
loop_forev
er’
from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/
connection/session.rb:133:in loop' from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/ connection/channel.rb:269:in
wait’
from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ssh/
connection/session.rb:327:in exec!' from (irb):4 from C:/ruby/lib/ruby/gems/1.8/gems/net-ssh-2.0.1/lib/net/ ssh.rb:189:in
start’
from (irb):3
irb(main):006:0>
Any help would be greatly appreciated.
Thanks,
Mike.