How to apply a terminal script using ssh to all users

scriptssh

I need to disable Google chrome's print preview option using the script
"defaults write com.google.Chrome DisablePrintPreview -boolean true -contributed by CutMaster", to a mac using ssh and apply this to all users.

The script above only works when you enter it when logged in as a user. However, I do not have access to the user's account but I do have access to the admin account.

Your help is much appreciated.

Best Answer

Use the sudo command

The command is sudo -u username command

So, after you SSH in as the admin, issue the command:

sudo -u <username> defaults write  /Users/<username>/Library/Preferences/com.google.Chrome.plist D
isablePrintPreview -boolean true

That will set the preferences value for the particular user you are interested in without having to know their password.

I personally checked this on OS X 10.11.4 using an account called "testguy". I was able to SSH into the machine, set the preferences using the command you provided and verify that it was set by issuing the command:

sudo -u testguy defaults read  /Users/testguy/Library/Preferences/com.google.Chrome.plist Di
sablePrintPreview  

The response was 1 (true)