To manual switch on remote access from the terminal:
ssh username@mac_ip_address
cd /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources
sudo ./kickstart -activate -configure -access -on -privs -all -restart -agent
To switch this override back off and thus allow the System Preferences to manage screen sharing again run the following. (This will disconnect any active sessions and require physical access to re-enable it.)
sudo ./kickstart -activate -restart -agent