How to enable Screen Sharing on Macs via Terminal
By executing a simple command, you can enable Screen Sharing on your Mac to interact with the system via a remote connection.
A client's MacBook Pro recently experienced a problem with the cursor--it got stuck and wouldn't move. The client was trying to complete work by deadline and couldn't wait a few days to get the issue resolved through Apple.
Since the client had a second Mac available, I decided to enable Screen Sharing on the MacBook Pro via Terminal, which allowed access to the faulty laptop over the network from the iMac and, more importantly, allowed the client to complete the work on time.
SEE: Wireless networking policy (Tech Pro Research)
While some users can likely get away with simply connecting a USB mouse or using a backup on another device until their laptop is fixed, those solutions won't work for everyone. In this case, the USB mouse was not a useful workaround, the data was work related, and a backup was not possible due to security reasons, which further complicated matters.
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.
Also see
- Fix your Mac with these simple troubleshooting tips (ZDNet)
- 10 signs that you aren't cut out to be a telecommuter (free PDF) (TechRepublic)
- How to enable SSH via Terminal (TechRepublic)
- How to change HostNames via Terminal (TechRepublic)
- How to manage Wi-Fi with Terminal commands on OS X (TechRepublic)
- Mac Terminal basics: Unlock the power of the command line (TechRepublic)
If you have experienced any weird Mac-related issues, what out-of-the-box solutions resolved the problems? Let us know in the comments.