Octopus Bash Run as another user

Hi All,

I am using the Bash commands within Octopus for the first time and noticed that it is running as root as all files being created have the user root against them.

I have attempt to do both a “su MyUserName” at the start of the script and also attempt to add “sudo -u MyUserName” in front of my file copy commands

e.g. “sudo -u octopusUser cp -r “${targetdirectory_sv}/.” “${deploymentdir}sv/””

Keep in mind the script does a chown -R octopusUser $targetDirectory_Sv first to ensure that the files are already owned by OctopusUser prior to the cp, but the files in deploymentdir/sv are still coming across with the user of root.

Anybody have any suggestions?

Thanks,
Damien

Hi @damien_taylor!

Sadly, there’s no simple way of doing this on a script-by-script level, but one option you could do here is reconfigure the tentacle systemd service to run as octopusUser instead of root, if you intend to have everything run as octopusUser.

If you’re interested in this, we have a step-by-step for configuring the tentacle as a non-root user here: Can I run the Octopus Deploy Linux Tentacle as a non-sudo / non-root user?

I hope this helps, and please let us know if you have any further questions.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.