Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'rubygems'
- require 'net/ssh'
- host = "10.20.30.45"
- user = "king"
- pass = "Badp@ssw0rd"
- commands = ["cd /tmp/" , "pwd" , "echo 'Ruby' > ruby.txt" , "cat ruby.txt"]
- Net::SSH.start(host, user , :password => pass , :port => 15000 , :timeout => 7 ) do |ssh|
- ssh.open_channel(type="session") do |channel|
- channel.request_pty(:modes => { Net::SSH::Connection::Term::ECHO => 0 }) do |pty, success|
- channel.on_data do |ch1, data|
- commands.each do |cmd|
- channel.send_data(cmd + "\n")
- puts data
- end
- end
- puts channel.exec("sudo bash")
- end # end of pty
- end # end of channel
- ssh.loop 0.1
- end
- #]0;root@pdbosl02:~
- #]0;root@pdbosl02:~
- #]0;root@pdbosl02:~
- #]0;root@pdbosl02:~
- #
- #
- #
- #
- #[root@pdbosl02 ~]#
- #[root@pdbosl02 ~]#
- #[root@pdbosl02 ~]#
- #[root@pdbosl02 ~]#
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #
- #
- #
- #
- #[root@pdbosl02 tmp]#
- #[root@pdbosl02 tmp]#
- #[root@pdbosl02 tmp]#
- #[root@pdbosl02 tmp]#
- #/tmp
- #/tmp
- #/tmp
- #/tmp
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #
- #
- #
- #
- #[root@pdbosl02 tmp]#
- #[root@pdbosl02 tmp]#
- #[root@pdbosl02 tmp]#
- #[root@pdbosl02 tmp]#
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #
- #
- #
- #
- #[root@pdbosl02 tmp]#
- #[root@pdbosl02 tmp]#
- #[root@pdbosl02 tmp]#
- #[root@pdbosl02 tmp]#
- #Ruby
- #Ruby
- #Ruby
- #Ruby
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
- #]0;root@pdbosl02:/tmp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement