Hi,
I figured out the answer to my original post. I used the PuTTy SSH
packets logging feature and was able to to make a script that mimicked
how PuTTY interacts with a Cisco Wireless LAN controller (WLC) when
logging in using SSH.
In a nutshell; you have to request an 'xterm' PTY (virtual terminal)
on the WLC, then request a new shell be created. Once I did that I
could see the WLC prompting for login credentials. After this is was
just a matter of sending strings as WLC commands over the channel.
Below is a basic script showing how I accomplished this:
require 'net/ssh'
#Open a new SSH connection
Net::SSH.start('1.1.1.1', 'username', :password =>
"password", :verbose => Logger::DEBUG) do |ssh|
#Open a new channel
ssh.open_channel do |channel|
channel.request_pty(:term => "xterm") do |ch, success|
if success
puts "pty successfully obtained"
ch.send_channel_request "shell" do |ch, success|
if success
puts "user shell started successfully"
ch.on_data do |ch, data|
puts "got stdout: #{data}"
end
ch.send_data("username\n")
ch.on_data do |ch, data|
puts "got stdout: #{data}"
end
ch.send_data("password\n")
ch.on_data do |ch, data|
puts "got stdout: #{data}"
end
ch.send_data("show ap summary\n")
ch.on_data do |ch, data|
puts "got stdout: #{data}"
end
ch.send_data("logout\nn\n")
ch.on_eof do |ch|
puts "remote end is done sending data"
ch.do_close
end
else
puts "could not start user shell"
end
end
else
puts "could not obtain pty"
end
end
end
end
Hope this can help someone.
Mike.