Set up Screen Sharing (VNC) via command line on Mac OS X remotely using SSH

Locked out of a Mac because Remote Desktop has suddenly taken a crap on you? Want to remotely enable Screen Sharing (Apple’s fancy name for VNC)? Well, as long as you have SSH active, you can enable Screen Sharing on Mac OS X 10.5 by following these easy instructions.

SSH into the machine on which you want to enable VNC.

EDIT 2/23/2017: If you don’t want to enable Apple remote management, but instead ONLY want to enable screensharing, use the two commands below in Terminal:

sudo defaults write /var/db/launchd.db/ -dict Disabled -bool false
sudo launchctl load -w /System/Library/LaunchDaemons/

EDIT 2/12/2009: Thanks to David Jones for pointing out a document from Apple which details a command-line equivalent to all the steps detailed in my original post. Instead of the original directions posted here, simply execute the following command after SSHing into the target machine in order to enable screen sharing for the admin user and restart ARD. This will enable Apple Remote Management:

$ sudo /System/Library/CoreServices/RemoteManagement/ -activate -configure -access -on -users admin -privs -all -restart -agent -menu



First, we need to make sure that Remote Desktop is turned OFF. Issue the following command:

sudo /System/Library/CoreServices/RemoteManagement/ -deactivate -stop


Enter your administrator password if requested.

Then, navigate to /Library/Preferences/

cd /Library/Preferences


We’re going to create three text files there, which set up the preferences for Remote Management and VNC.

sudo tee


Enter your administrator password. Then, copy and paste the following text:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" ""><plist version="1.0">


Press return, then press CTRL-d to close the file.

sudo tee


Enter your administrator password if prompted. Then, copy and paste the following text:



Press return, then press CTRL-d to close the file.

Set the default VNC password to “pass” by creating this file:

sudo tee


and copying and pasting the following text:



Press return, then press CTRL-d to close the file.

Let’s change the ownership and permissions on these files to their correct values:

sudo chmod 644
sudo chown root:admin
sudo chmod 644
sudo chown root:admin
sudo chown root:wheel
sudo chmod 400


Let’s set up launchd to automatically launch Screen Sharing on startup:

sudo echo enabled > /Library/Preferences/

sudo bash -c 'echo enabled > /Library/Preferences/'


Finally, let’s reboot the machine:

sudo reboot


You can now VNC into your Mac, using either Leopard’s built in screen sharing or a third party VNC utility. On Mac, I recommend Chicken of the VNC, available for free download at Point your app of choice to your machine’s IP address or hostname. When prompted for a password, use the default one from above (pass).

Once you’re in, you need to go to System Preferences -> Sharing -> Screen Sharing, and click the “Computer Settings” button. There, enter in a new password to replace the default used at the beginning steps of this article.

10 thoughts on “Set up Screen Sharing (VNC) via command line on Mac OS X remotely using SSH

  1. This worked for me.

    The only thing that’s wrong is the use of the sudo echo enabled > “” command – sudo will run the echo as root but bash won’t have permission to rewrite the file. Change to tee like the above examples.

  2. @Mark: Good catch. Thanks for sharing. I’ve modified the original article to reflect your comment.

  3. Pingback: the blogging » It’s tough to use a computer with no display

  4. Thanks so much for this. Worked a treat. I didn’t want to reboot my Mac, though, so a bit more searching on the net (and a bit of extrapolation) produced this command:

    sudo /bin/launchctl load /System/Library/LaunchAgents/

    …which started up the VNC server without rebooting. I’m in via TightVNC from my windows box at work. Pain in the rear fighting with the screen saver to log in though. Eventually got it.

  5. Pingback: Ryan’s Tech Notes » Blog Archive » Enabling Remote Access to Apple OS X Leopard via SSH Command Line

  6. For some reason my kickstart (ARD) & associated files got hosed – so the Apple method was useless. This method works fine except no “>” required

    sudo bash -c ‘echo enabled /Library/Preferences/’

    allowed me to use Chicken of the VNC and correct the ARD issues

  7. Hey Brewer – good write-up. My mac’s graphics card appears to be dead, and I searched around looking for exactly this. How cool that it turned out to be your article. talk at ya on FB soon – Orstead

  8. Pingback: links for 2010-02-05 (Jarrett House North)

  9. Pingback: VNC OS X - przyda?o si? :) -

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.