Is there a way to run Shipit "remote" commands that use "sudo" with a non-root user?

While using the Shipit automation engine, I found that trying to run commands with "sudo" as a non-root user (call this "devuser") was causing the connection to be closed without executing the command .
This is the command I am trying to execute:

shipit.remote (' sudo pwd');

Note that on the target machine "devuser" can do everything with "sudo" without asking for his password (this is the target system's choice).
Also note that anything called without "sudo" (and obviously doesn't require elevated permission) is automatically handled by the Shipit penalty.
For example, this works very well:

shipit.remote ('PWD');

The question at this point is: Am I doing something wrong or is this by design (e.g. to avoid escalating privileges)? If it is the latter: is there a way to limit this limitation?

+3


source to share


1 answer


a simple hack for this is to set a user inside every command you use with shipit

. This is a bit of an overhead, especially if there are many commands, but it will be a trick. The command for this:

su - <user> -c "<command>"

      

In your case:



shipit.remote('su - devuser -c "pwd"');

      

You were on the right track with your example.

Regards, Nikola

+2


source







All Articles