Pushing Scripts via Capser Remote

dstranathan
Valued Contributor II

Dumb question...

When pushing out bash scripts that require root privileges via Casper Remote, do I need to explicitly escalate permisions via the sudo command?

Simple Example: I created a simple bash script to tell managed Macs to run Apple Software Update...

Is this acceptable:

!/bin/bash

/usr/sbin/softwareupdate -i -a

Or do I need to do this:

!/bin/bash

sudo /usr/sbin/softwareupdate -i -a

I assume jamf runs as root?

5 REPLIES 5

mm2270
Legendary Contributor III

It should be running them as root, same as it would when running from a policy, but since I probably only use Casper Remote like once a year at best, you may want to test it to be sure.

dstranathan
Valued Contributor II

Thank you sir. I just started (seriously) playing with Casper Remote today. Wondered if "sudo" was redundant or not.

stevewood
Honored Contributor II
Honored Contributor II

It is redundant. Casper Remote actually creates hidden policies in the JSS and runs the commands like a policy. So whether you use a policy or Casper Remote, you're doing the same thing.

thoule
Valued Contributor II

Casper remote does run via policies. It creates a hidden policy, tells the client to execute it, then removes that policy. There was a post here about a month or so ago describing how it works internally. So Casper Remote or Policy all run the same.

sudo is certainly redundant. All scripts execute as root. Additionally, as you may know, many environment variables are skipped. That means you should set the full path to commands in your script, such as instead of 'launchctl list', you'd use '/bin/launchctl list'.

mm2270
Legendary Contributor III

Yeah, the post describing how Casper Remote works may have been this one? https://jamfnation.jamfsoftware.com/featureRequest.html?id=4343#responseChild13197 From me ironically enough, although maybe it was a different one.
Anyway, yes, it runs stuff as root, because it really is just executing a policy in the end.