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 you want to enable VNC on.

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

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -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 com.apple.RemoteManagement.plist

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

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0">
<dict>
<key>ARD_AllLocalUsers</key>
<false/>
<key>LoadRemoteManagementMenuExtra</key>
<true/>
<key>ScreenSharingReqPermEnabled</key>
<true/>
<key>VNCLegacyConnectionsEnabled</key>
<true/>
</dict>

</plist>

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

sudo tee com.apple.ScreenSharing.launchd

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

enabled

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

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

sudo tee com.apple.VNCSettings.txt

and copying and pasting the following text:

6755221D8BA8C5E2FF1C39567390ADCA

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 com.apple.RemoteManagement.plist
sudo chown root:admin com.apple.RemoteManagement.plist
sudo chmod 644 com.apple.ScreenSharing.launchd
sudo chown root:admin com.apple.ScreenSharing.launchd
sudo chown root:wheel com.apple.VNCSettings.txt
sudo chmod 400 com.apple.VNCSettings.txt

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

sudo echo enabled > /Library/Preferences/com.apple.ScreenSharing.launchd

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 http://sourceforge.net/projects/cotvnc/. 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.

Gregarious FeedFlare
Powered by Gregarious (42)

About this Piece O' Garbage

Join the fray by contributing trash, feeding on other people's trash, or linking to it from your dump.


Other Garbage Nearby
Restore 30 second commercial skip to your Motorola DCT 6416 DVR

Talk Some Trash

Take a moment to submit some trash to this garbage pile. Some basic HTML is allowed for formatting.

Reader Trash in this Garbage Pile

Be the first to talk trash!



Close
E-mail It
Socialized through Gregarious 42