Connect to a Cisco switch with SSH and Ruby -
i'm trying connect cisco switch ssh , ruby. problem need enter empty 'login as' ask me user name , password. on putty this:
here how have tried connect net::ssh.
cisco = "host" #enter ip address here user = "operacao" #enter username here pass = "" #enter password here tn = net::ssh::telnet::new("host" => cisco, "timeout" => 60, "prompt" => /^\login as:/ ) tn.cmd("\n") { |c| print c } tn.cmd("\n#{user}") { |c| print c } tn.cmd(pass) { |c| print c } tn.print("echo oi") { |c| print c } tn.close
is there way ruby?
i find sample here hope gives direction. before run code certify run:
gem install net-ssh
#!/usr/bin/env ruby require 'net/ssh' host = '192.168.1.113' user = 'username' pass = 'password' net::ssh.start( host, user, :password => pass ) do|ssh| result = ssh.exec!('ls') puts result end
the requirement of net::ssh openssl bindings ruby, can check if ok this:
c:\sites>ruby -ropenssl -e 'puts openssl::openssl_version' openssl 1.0.0k 5 feb 2013 c:\sites>
edit:
did research , found answers, think should take at:
telnet cisco switch ,
net-ssh configure juniper router
Comments
Post a Comment