Jul 28 2012

Changing VNC password from Mac OSX terminal

As many of you might have already know MAC OSX has a somewhat integrated version of the ever popular VNC server under the name of screen Sharing; this will allow you to connect to the desktop of another MAC. This is all great, however what if you are not able to access that Mac to change the password and you only have SSH access into the device how can you change the password to allow you desktop access?

Don’t get me wrong being an enthusiast  of Linux I dont have a problem working from the terminal but certain things are better done with the GUI if you are pressed for time.

Some background; once you have enabled remote management and screen sharing on a MAC the following files are created within the /Library/Preferences folder:

  • com.apple.RemoteManagement.plist
  • com.apple.ScreenSharing.launchd
  • com.apple.VNCSettings.txt

If these files are not present then this service was not enabled and you can manually create these files from the terminal using your favorite text editor. The file of interest to us today is com.apple.VNCSettings.txt , this file contains a hashed value of the VNC password a simple 32 character alphanumeric string.

By default this file has a permission of 400 or read only and is only accessible to Root. So after I noticed that this file was present, I immediately changed the permission so I could read it and started thinking of ways to reverse the file. Since time was of the essence  I did the following instead:

  1. Change the file permission:

chmod 777 com.apple.VNCSettings.txt

2. Next I created a VNC password on a MAC that I have access too then SSH into that MAC and copied the   hash value from that machine’s version of com.apple.VNCSettings.txt

3. I then SSH back into the original MAC that I was locked out of and echoed that new value into the same file on the first MAC.

$ echo “A8G8B8AOD8FHA8DFAHD8F” > com.apple.VNCSettings.txt

 4.  Lastly just restart the service and logo with your newly created password

 $ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -restart -agent

Have fun and let me know if it worked! Sometimes the easiest solutions are the best ones :)

One Response to “Changing VNC password from Mac OSX terminal”

  1. Joanna says:

    Great that you write about us, thank you so much!

    Write to me if you want to become our independent author,

    Bests,
    Joanna

Leave a Reply

You must be logged in to post a comment.

Alibi3col theme by Themocracy

css.php
More in Uncategorized (1 of 4 articles)