Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

10.5: Start screen sharing remotely in Terminal Network
Assume you want to do some work on a remote Mac via 10.5's Screen Sharing, but you forgot to enable Screen Sharing before you left the remote Mac. You're now a good distance away, and apparently stuck. Fortunately, because the screen sharing system uses launchd to monitor its state, enabling and disabling is as simple as adding a file in the remote Mac's /Libary/Preferences folder. (Note that you'll need to be able to login to the remote Mac via ssh to run these commands on that Mac.)
$ cd /Library/Preferences
$ echo -n enabled > com.apple.ScreenSharing.launchd
To disable screen sharing:
$ cd /Library/Preferences
$ rm com.apple.ScreenSharing.launchd
If you have a Finder window open with the remote Mac selected in the Shared section, you'll even note the icon for Screen Sharing coming and going as you do this.
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[25,755 views]  

10.5: Start screen sharing remotely in Terminal | 12 comments | Create New Account
Click here to return to the '10.5: Start screen sharing remotely in Terminal' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
10.5: Start screen sharing remotely in Terminal
Authored by: Pedro Estarque on Tue, Mar 25 2008 at 8:27AM PDT
Wouldn't you need do sudo since you are in root /Library ?

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: leamanc on Tue, Mar 25 2008 at 9:17AM PDT
Not if you are an admin user. You would need root power to write /System/Library.

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: leamanc on Tue, Mar 25 2008 at 11:46AM PDT
Correcting myself somewhat.

As is implied in the hint, you can write to /Library/Preferences as an admin user without using root.

Writing to directly to /Library, however, requires root power, as that folder is read-only for admin users (most of the subfolders are writable by the admin group, though).

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: Pedro Estarque on Tue, Mar 25 2008 at 7:11PM PDT
Actually I think this is the correct situation:
If the user has created the launchd file through the System Prefs sharing panel, than you'll need sudo to rm it. But if it's disabled in System Prefs, than yes, you can run the command as admin only, as you have write access to the Preferences folder.

In short, you have write access to the folder as an admin but not to the file created by the System Pref.

Great tip by the way!

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: corienti on Tue, Mar 25 2008 at 1:41PM PDT
Not if you're logged in as root :-)

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: luigi193 on Tue, Mar 25 2008 at 10:39AM PDT
OMG awesome hint!!!!

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: shapiro on Wed, Mar 26 2008 at 9:17AM PDT
This should always work:
[code]
sudo sh -c "/bin/echo -n enabled > /Library/Preferences/com.apple.ScreenSharing.launchd"
[/code]

all on one line.

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: ccjensen on Thu, Mar 27 2008 at 5:33AM PDT
this doesn't seem to work quite right. If I have screen sharing turned on in my servers system preferences, and log in using screen sharing and disable it using the system preferences GUI, I lose the connection.
If I do the same, but instead of using the GUI I delete the file from the terminal, the connection remains and I can disconnect and reconnect. I shouldn't be able to do this if the screen sharing plist file is gone. Any ideas?

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: joelbruner on Thu, May 29 2008 at 9:23AM PDT
I recall hearing at WWDC about how the plists are read in by the GUI tools using Cocoa events (or Apple Events called by a Cocoa app) this is the case for many plist controlled items like screensaver password and some others. So when you delete a plist you need a way to fire of the right event to the system so it refreshes. (No I haven't Googled it but there's the hint :)

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: wOOge on Wed, Jun 25 2008 at 6:39AM PDT
AWESOME hint... save my arse many times.

---
wOOge
http://www.axonz.com

[ Reply to This | # ]
10.6: Start screen sharing remotely in Terminal
Authored by: dmarkow on Fri, Sep 11 2009 at 7:18AM PDT
In Snow Leopard (10.6), you need to do this to the file /private/etc/ScreenSharing.launchd instead of /Library/Preferences/com.apple.ScreenSharing.launchd

[ Reply to This | # ]
10.5: Start screen sharing remotely in Terminal
Authored by: buttercupp on Thu, Sep 17 2009 at 11:43AM PDT
Very cool tip, worked great. Thanks!

[ Reply to This | # ]