Looking at the LXD API execute docs shows that user and group IDs can be set:
https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10instancesnameexec
This doesn’t appear to be exposed in the Instance.execute method of PyLXD. Any reason its not included, could this be added ? Would be cleaner then wrapping up commands in su and sudo.
Probably just a feature that the pylxd team didn’t add yet. You should be able to send a pretty simple pull request to add it.
@ack
FYI
@Jonan I was facing same error about LXD API execution. I tried many time to solve it. I saw you post thanks for sharing this post.