Open slhck opened 4 years ago
it is ssh problem (or say security measure), you should use "sudo yourcmd" each time
it is ssh problem (or say security measure), you should use "sudo yourcmd" each time
No, sudo yourcmd
shows the same error because it asks for the password and hss doesn't provide a tty (i think?), i'm still looking for a solution
@six-ddc could you please suggest how to deal with the inability to run a command with sudo
?
I tried hss -H '-tt hostname'
but hss can't work this way. What is an alternative solution that works for you?
@avently As mentioned above, If your sudo cmd
requires a password, it is not supported in batch mode like hss
(no tty), maybe you should setup no-password in /etc/sudoers
. https://askubuntu.com/questions/334318/sudoers-file-enable-nopasswd-for-user-all-commands
I could setup it but I prefer to enter a password because this way I know when scripts I run require a sudo command execution (which is not always a good idea so I can Ctrl+C
in this case).
Is it possible to support providing tty somehow (technically)?
P.S. I made a bash function that can run commands with sudo cmd
on a list of servers but it can't work in parallel because if no tty
too
I have given up on finding a solution for this with bash tools. I now use Ansible for such tasks. It handles sudo well. Use the ad hoc mode to run arbitrary commands.
Basically, you can set up an inventory file and then run:
ansible all --ask-become-pass --become -a 'apt install blah'
This will run the command with sudo on all (all
) hosts defined in the inventory.
@avently Try this way echo <password> | sudo -S <command>
. One command, and 'sudo' explicitly.
@six-ddc this trick will work only if you have the same password on all servers and you want to run one command with root. Also it's not a good thing for security to have password printed in a list of processes. So, better to use for such cases one-liner in bash which allows to enter a password in a right way. Or to use Ansible, as stated above. If it's technically possible, I would prefer native support in hss.
For example, using this command I almost able to enter a password, but hss doesn't work this way correctly:
hss -H '-tt host'
$ sudo ls
(shows nothing)
^C
(prints) [sudo] password for user: $ ^C
So close to solution:)
When running
sudo
I get:Is there any way to circumvent this?