Skip to content

Instantly share code, notes, and snippets.

@nateware
Created October 19, 2012 01:27
Show Gist options
  • Save nateware/3915757 to your computer and use it in GitHub Desktop.
Save nateware/3915757 to your computer and use it in GitHub Desktop.
Start Mac VNC server from command line
# Step 1: Set priveleges
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -allUsers -privs -all
Starting...
Setting allow all users to YES.
Setting all users privileges to 1073742079.
Done.
# Step 2: Allow VNC clients
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -clientopts -setvnclegacy -vnclegacy yes
Starting...
Set the client options.
Done.
# Step 3: Set VNC password (change it at the end of the line (i.e. don't use supersecret))
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -clientopts -setvncpw -vncpw supersecret
Starting...
Set the client options.
Done.
# Step 4: Restart service
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -restart -agent -console
Starting...
Stopped ARD Agent.
Stopped VNC Privilege Proxy
Stopped RFB Register MDNS
Done.
# Step 5: If no ARD services have been activated on the machine before, it is also necessary to run the following command
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate
Starting...
Activated Remote Management.
Done.
@abhi-io
Copy link

abhi-io commented Dec 28, 2020

@nateware you just saved my day (20.5hrs)
worked on
Amazon EC2 macOS Catalina 10.15.7, and
Amazon EC2 macOS Mojave

endpoint details are - IP, Username, Pass

@hisashiyamaguchi
Copy link

Great script. It's working on BigSur too.

% uname -a
Darwin ip-172-31-30-21.us-east-2.compute.internal 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64

@nicksweb
Copy link

nicksweb commented Nov 3, 2021

Love this script, have used it a few times to get me out of trouble.

@F-WRunTime
Copy link

On Mac OS 12.3 Any advice on how this works now? I get the following errors and I am able to login but get a black screen.

Trying to read up on this MDM configuration stuff but sounds relatively new and I'm not a Mac person so I'm not very familiar with how to manage these machines from a fully remote setting.

Screen recording might be disabled. Screen Sharing or Remote Management must be enabled from System Preferences or via MDM.
Screen control might be disabled. Screen Sharing or Remote Management must be enabled from System Preferences or via MDM.

@artshade
Copy link

artshade commented Oct 2, 2022

On Mac OS 12.3 Any advice on how this works now? I get the following errors and I am able to login but get a black screen.

Trying to read up on this MDM configuration stuff but sounds relatively new and I'm not a Mac person so I'm not very familiar with how to manage these machines from a fully remote setting.

Screen recording might be disabled. Screen Sharing or Remote Management must be enabled from System Preferences or via MDM.
Screen control might be disabled. Screen Sharing or Remote Management must be enabled from System Preferences or via MDM.

Similar issue. Not a Mac user and would definitely appreciate any suggestion to enable the built-in VNC server via terminal.
Related: https://support.jumpdesktop.com/hc/en-us/articles/216425923-Mac-How-do-I-enable-the-VNC-Server-built-into-the-Mac-

@spamshaker
Copy link

how to define headless resoulution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment