I have problem with running the sudo command over a SSH connection using Ruby:
require 'net/ssh'
Net::SSH.start("myserver.com", "login", :password => "pass") do |ssh|
test = ssh.exec! 'sudo -iu admin /folder/script.sh'
puts test
The result I see next: "sudo: sorry, you must have a tty to run sudo\n"
But when I run this command:
sudo -iu admin /folder/script.sh
in PUTTY with connect to server 'myserver.com' with password 'pass'. In this case the sudo command runs successfully and completes.
How I can run this sudo command in a Ruby script with TTY?