Monday, March 23, 2009

Start VNC from command line and connect to Mac from Windows VNC client

Here is how to start VNC from command line on your macintosh (say, via ssh) and then connect to your Macintosh from a Windows VNC client


Server side (SSH to your mac):


Step 1: -- set privs


Badabing:~ rob$ 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


Badabing:~ rob$ 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))

Badabing:~ rob$ 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

Badabing:~ rob$ 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.

Badabing:~ rob$


Step 5: -- Client side config

Windows (Client Side)

I installed the tightVNC viewer.

Enter IP address in the VNC Server field. Click "Options" Change Encoding to Hextile. Click ok.

Click Connect.

Enjoy.

16 comments:

Unknown said...

This is a fantastic tutorial! It worked the first time for me and now I can work from home!

Thank you!

MANOJ said...

Thanks for such a good posting.

MANOJ said...

Thanks for such a good posting

sujith said...

Thank you soooooooooo Much :)..... worked for me..

Denis Parra said...

you > chuck norris

Unknown said...

Excellent tutorial, worked first time through. Thank you.

Abu Hawa said...

It works on Mac OS Lion Server too as the default Screen Sharing and Remote Management in the Server app does not show function to enable vnc password unlike the normal Mac OS Lion. So, your tutorial here seem the only mean to enable vnc remote desktop for Lion Server

Jon said...

Works on Lion, but I was unable to set a long password. I truncated to 8 characters and it worked fine. Since Lion forces you through a normal account login screen anyway though, short passwords seem safe to me.

Ray said...

Thank you! This was a clear and concise tutorial, well done!

Michael A. Lowry said...

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

Aaron Mulder said...

The step in the last comment was crucial for me, thanks!

Unknown said...

Many, many thanks. Awesome. Works perfectly.

Kris Coady said...

Worked great here on a Mac OS X Mountain Lion machine

Gwyneth Llewelyn said...

Many thanks! This made my day!

Kudos to @Michael A. Lowry as well, without that last command, I would have been at a loss to figure out why nothing was listening on port 5900...

Unknown said...

can you provide instructions to undo everything and close out when you no longer need the ability to remote in.

thanks!

K R Naidu said...

Thank you so Much :)..... worked for me on Mac OS X Server 10.7.3 perfectly...thanks lot..