How to enable Screen Sharing on Macs via TerminalОпубликовано вт, 02/05/2019 - 13:44 пользователем Maxim
Follow these steps to enable Screen Sharing via Terminal.
1. Navigate to Applications | Utilities and launch Terminal. If you're working from a keyboard only, press Command+Space Bar to launch Spotlight, and then enter Terminal in the search box to launch the app.
2. Enter the following command into Terminal and press Enter to execute it. You will be prompted to provide admin credentials prior to processing the command.
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -off -restart -agent -privs -all -allowAccessFor -allUsers
The command above will work most of the time, as it uses the kickstart method of enabling remote management, which in turn enables Screen Sharing as well for all users of the device. This isn't the most secure method and it's not recommended to be used like this for long periods of time due to the potential security risks of unauthorized access, but it should serve you well as a temporary workaround for the problem.
If maintaining security is a requirement, then entering the command below will only enable Screen Sharing.
sudo defaults write /var/db/launchd.db/com.apple.launchd/overrides.plist com.apple.screensharing -dict Disabled -bool false
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
Your Mac now has Screen Sharing enabled, and it should be accessible remotely from another Apple computer by launching the Screen Sharing app and entering the host Mac's computer name or IP address. Visit this page for getting more information.