Why would net-ssh not be able to execute the useradd
command?
This is my net-ssh code:
Net::SSH.start(host, user, forward_agent: true) do |ssh|
ssh.open_channel do |ch|
ch.request_pty
ch.exec "mkdir /tmp/unicorn"
ch.exec "sudo groupadd unicorn"
ch.exec "sudo chgrp unicorn /tmp/unicorn"
ch.exec "sudo useradd application" do |ch, success|
if success
puts 'command worked'
else
puts 'command failed'
end
end
end
end
All of the commands work except for the useradd
command. I can log in and run the useradd
command and a user is added.
Thanks, Eric