execute remote commands with sudo #54

Open
opened 2021-11-20 11:25:15 +00:00 by ungleich-gitea · 6 comments

more and more I'm in situation where I don't get root with VM or it's even forbidden to do sudo -i. there are many reasons for that. from overzealous security policy writes who see root as root of all evil to monitoring and auditability of operator actions. YMMV of course, but we can't ignore the fact that this is happening and it's a new norm just like Gospel of systemd brought to you by Church of Lennart.

fun fact is that sudo is often allowed without password in situations where all non-system users present in system are admins anyway. shared systems with some users in sudoers group is different issue and isn't in scope imho.

what must be done:

  1. all necessary files must be copied to executing user's context in target host (~/.cdist/exec?). imho that should be default even if we use root.
  2. directories and files in executing user context must be create without sudo
  3. remote code must be executed with sudo

discuss.

more and more I'm in situation where I don't get root with VM or it's even forbidden to do ``sudo -i``. there are many reasons for that. from overzealous security policy writes who see root as root of all evil to monitoring and auditability of operator actions. YMMV of course, but we can't ignore the fact that this is happening and it's a new norm just like Gospel of systemd brought to you by Church of Lennart. fun fact is that ``sudo`` is often allowed without password in situations where all non-system users present in system are admins anyway. shared systems with some users in sudoers group is different issue and isn't in scope imho. what must be done: 1. all necessary files must be copied to executing user's context in target host (`~/.cdist/exec`?). imho that should be default even if we use root. 2. directories and files in executing user context must be create without sudo 3. remote code must be executed with sudo discuss.
Author
Owner

yeah, something like $TMP/cdist-$USER with mode 0700 would be nice too.

yeah, something like `$TMP/cdist-$USER` with mode `0700` would be nice too.
Author
Owner

Not sure whether I like ~/.cdist/exec.
I'd propose to use /tmp for temporary files. It is also always writable by users.
If permissions are a concern the cdist temp directory could be owned by the executing user and have mode 0700.

Not sure whether I like `~/.cdist/exec`. I'd propose to use `/tmp` for temporary files. It is also always writable by users. If permissions are a concern the cdist temp directory could be owned by the executing user and have mode `0700`.
Author
Owner

It isn't.

For example, how would you write --remote-copy with sudo? :)

It isn't. For example, how would you write `--remote-copy` with sudo? :)
Author
Owner

@ander You can use --remote-exec/--remote-copy custom settings to do it with sudo/non-root user. Or this isn't enough?

@ander You can use --remote-exec/--remote-copy custom settings to do it with sudo/non-root user. Or this isn't enough?
Author
Owner

changed the description

changed the description
Author
Owner

changed the description

changed the description
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ungleich-public/cdist#54
No description provided.