Class: SSHKit::Backend::Netssh
- Inherits:
-
Object
- Object
- SSHKit::Backend::Netssh
- Defined in:
- lib/addon/sshkit_monkey_patch.rb
Instance Method Summary collapse
- #put(strings, remote, options = {}) ⇒ Object
- #su_run(user, cmd) ⇒ Object (also: #su_execute)
- #sudo(cmd) ⇒ Object
Instance Method Details
#put(strings, remote, options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/addon/sshkit_monkey_patch.rb', line 6 def put strings, remote, = {} local = StringIO.new strings upload! local, remote, end |
#su_run(user, cmd) ⇒ Object Also known as: su_execute
11 12 13 |
# File 'lib/addon/sshkit_monkey_patch.rb', line 11 def su_run user, cmd execute %Q(su - #{user} -c "#{cmd}") end |
#sudo(cmd) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/addon/sshkit_monkey_patch.rb', line 16 def sudo cmd SSHKit::Backend::Netssh.config.pty = true # p host password = host.password execute %Q( echo #{password} | sudo -kS bash -c "#{cmd}" ) # execute %Q(sudo bash -c "#{cmd}"), interaction_handler: { # /\(yes\/no\)/i => "yes\n", # /[sudo] password/i => "#{password}\n", # } end |