Open jzs opened 7 years ago
@VojtechVitek do you think we can add input for asking password?
Getting the same behaviour deploying on my CentOS server
Are all the examples done with passwordless sudo? Or is this an isolated problem? Haven't used sup yet myself but I'm very intrigued.
Yes, all the examples were done with password-less sudo.
It all comes down to the infrastructure set-up. From my experience, most of the companies use private/public SSH key pairs to login to the instances (sometimes via a bastion host) and then the sudo itself doesn't have password, but is restricted to certain commands (like. sudo docker
, ie. https://askubuntu.com/a/477554) etc.
There was some work done to make sudo
a Supfile option, but it was never finished. https://github.com/pressly/sup/pull/51
man sudo
-S, --stdin
Write the prompt to the standard error and read the password from the standard input
instead of using the terminal device. The password must be followed by a newline
character.
@VojtechVitek @alinz You dont' ask me, but IMHO: in this cases it's better to add cookbook with answers like this, than add a new feature that do exactly the same, but with new syntax.
I have a command in my Supfile
sudo systemctl restart myservice.service
.When running it against a localhost host it asks for a sudo password just fine, and accepts my input. However when running it against a remote ubuntu host, it doesn't show the password prompt and it looks like sup is hanging. When pressing ^C then it prints: [sudo] password for xxxx: followed by terminating the connection.
Adding:
stdin:true
seems to do the trick, however it then prints out[sudo] password for xxxx:
after i type my password. (It looks like it hangs, i write the password, it prints out [sudo] password for xxxx and then accepts the password i typed in. On the same time, my password is printed to the console when typeing. Hence noread -s
functionality.Alternatively adding
%xxxx ALL=NOPASSWD: /bin/systemctl stop myservice.service
to the sudoers file on the remote host also works. Since it will then skip asking for password.Here's a minimal Supfile to recreate my issue:
My Dev machine is running arch linux and the server is running Ubuntu 16.04.2 LTS.