Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'net/ssh'
- host="192.168.69.1"
- user='admin'
- pass='password'
- result=''
- Net::SSH.start(host, user, :password => pass) do |ssh|
- # Open a channel
- channel = ssh.open_channel do |channel, success|
- channel.request_pty
- channel.exec("help")
- channel.on_data do |channel, data|
- puts data
- # Send the password
- if data.include?("login")
- channel.send_data "#{user}\n"
- print("#{user} send user")
- end
- if data.include?("password")
- channel.send_data("#{pass}\n")
- print("#{pass} sending pass")
- end
- if data.include?('rkscli:')
- puts("exec cmd")
- channel.send_data("help\n"){|c,d| puts d}
- channel.wait
- end
- end
- end
- # Wait for opened channel
- channel.wait
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement