How to Enable and Configure macOS Screen Sharing via Terminal Command Line

macOS Screen Sharing (which uses the VNC protocol) is an excellent tool for remote administration. While it is easy to enable via the System Settings GUI, system administrators often need to enable it remotely over an SSH connection or push the configuration to multiple Macs via an MDM script. Fortunately, macOS includes a built-in command-line utility specifically for this purpose.

The kickstart Utility

The core of macOS remote management from the command line is a script called kickstart, located deep within the system directory at /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart. This tool allows you to activate the VNC server, configure access rights, and restart the necessary daemons.

How to Enable Screen Sharing for All Users

If you have SSH access to the remote Mac, you can instantly turn on Screen Sharing for all local users by executing the following command with root privileges:

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -users admin -privs -all -restart -agent -MenuExtra -yes

What this command does:

  • -activate: Starts the Remote Management service.
  • -configure -access -on: Enables remote access.
  • -users admin: Grants access to the user named “admin” (replace this with the actual username you want to grant access to).
  • -privs -all: Grants full control privileges to the specified user.
  • -restart -agent: Restarts the ARDAgent to apply the changes immediately.

How to Enable VNC for Non-macOS Clients

By default, macOS Screen Sharing expects connections from other Apple devices. If you need to connect from a Windows or Linux machine using a standard VNC viewer, you must set a legacy VNC password.

Run the following command, replacing YourPasswordHere with a strong password:

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -clientopts -setvnclegacy -vnclegacy yes -setvncpw -vncpw YourPasswordHere -restart -agent

You can now open a VNC client on any operating system, point it to the Mac’s IP address, and authenticate using the legacy password.

How to Disable Screen Sharing

To secure the machine and close the VNC port when remote administration is no longer required, simply deactivate the service:

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off

Mastering the kickstart command provides a powerful, scriptable method for managing remote desktop access across a fleet of macOS devices without ever needing physical access to the graphical interface.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.