Enable screensharing via SSH and setting password I am trying to enable VNC (Screen Sharing) on my Mac running OS X Yosemite
I have been able to run this command sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist (source) to turn VNC on.

The only issue running this command is, it sets a password automatically, in which I do not know what it is, I have to fix it by logging in physically to the computer.

Is there a way how I can enable VNC via SSH and setting the password as the users password?
If you need to set a VNC password - you might need to also kickstart the ARDAgent, you can use this command instead of just loading the plist:

sudo  /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw mypasswd -restart -agent -privs -all


The analogous command for using user/password of existing users would be:

sudo  /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -configure -allowAccessFor -allUsers -configure -restart -agent -privs -all


More detail and discussion at:

How to enable OS X screen sharing (VNC) through SSH?