Script to Create Sharing Only User Account on Mac
Organizations may need to share files and folders on devices with other users remotely, but they may want to restrict access to the device settings. Enterprises can set up sharing only user accounts on devices to accomplish this. However, creating an account manually on each device is a tedious task. Hexnode allows you to create sharing only user accounts remotely on macOS devices by executing custom scripts.
Scripting Language – Bash
File extension – .sh
Create a sharing-only user account
You can deploy the script given below to create a sharing-only user account on macOS devices. The script also allows you to customize the account by adding display names, profile pictures, and so on.
# Create a new user with the username Sharing user
sudo dscl . create /Users/Sharing\ user
# Give the display name of the user as David
sudo dscl . create /Users/Sharing\ user RealName "David"
# (Optional) Add a password hint
sudo dscl . create /Users/Sharing\ user hint "123456"
# (Optional) Set a profile picture.
sudo dscl . create /Users/Sharing\ user picture "/Provide path to the image.png"
# Replace “123456” with the required password for the user account.
sudo dscl . passwd /Users/Sharing\ user 123456
# Set the unique ID for the user. Provide an ID which is not already used.
sudo dscl . create /Users/Sharing\ user UniqueID 550
# Set the Group ID for the user
sudo dscl . create /Users/Sharing\ user PrimaryGroupID 20
# Deny shell access for the user
sudo dscl . create /Users/Sharing\ user UserShell /usr/bin/false
# No home directory for the user
sudo dscl . create /Users/Sharing\ user NFSHomeDirectory /dev/null