81

I forgot to turn on "VNC viewers may control screen with password", to enter on my working Mac, is there way to turn-on this feature remotely via SSH (I'm on WindowsXP now)?

2 Answers2

118

Source: http://technotes.twosmallcoins.com/?p=279 (archived)

Putty is a good SSH client for Windows.

  1. SSH into your remote OS X machine with an administrator’s log in and password.

  2. Enable Remote Desktop (a.k.a. Screen Sharing, a.k.a. VNC) with this command:

    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
    
  3. Login using a VNC client. As I mentioned, TightVNC worked for me; for some reason, RealVNC and UltraVNC didn’t. Your password is “mypasswd” (see the -vncpw flag in the above command; you can and should change this).

  4. When you are done, turn off screen-sharing using your SSH session:

    sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
    -deactivate -configure -access -off
    
Frak
  • 115
RobinJ
  • 1,298
  • 2
    Amazing! Works! –  Nov 04 '11 at 22:43
  • One thing that Mac RD quite unusable for me (very slowly)... as opossed to windows RDC, which is pretty good. –  Nov 04 '11 at 23:04
  • Have you tried Vine Server? –  Nov 04 '11 at 23:11
  • I've never worked with VNC before. Only with SSH once to let my desktop start downloading a file upstairs in my room so that my laptop didn't have to keep running in the living room :p –  Nov 04 '11 at 23:13
  • 3
    3+ years later and works perfectly in Yosemite. Thanks! – Jordan Feb 22 '15 at 02:19
  • What if I I'm on mac and want to enable screen sharing with linux? (so no putty there). What can I do? – Novellizator Oct 06 '15 at 14:33
  • 1
    Warning: this breaks with the "Remote Desktop Client Update v3.8.5" update. See here: https://discussions.apple.com/thread/7501620?start=15&tstart=0 – shrx Mar 28 '16 at 23:38
  • ... and the fix is here: https://discussions.apple.com/message/30088844#30088844 - download older RemoteManagement folder and replace the current, broken one with it. Direct link: http://rmscomputersystems.com/~pscordam/RemoteManagement(ARDAgent3.8.4).zip – shrx Apr 30 '16 at 16:00
  • 1
    @Novellizator Both Mac and Linux have ssh available out of the box. No need for a separate package like you need on Windows. – Christopher Schultz Jul 15 '16 at 00:40
  • TigerVNC worked for me on this. Vinagre, unfortunately, did not (it requires entering the username). – Drew Chapin Jul 24 '16 at 16:30
  • Would be helpful to disable not screen sharing, but only the VNC option – lobi Jun 19 '17 at 15:54
  • on OSX 10.13.6 ok – AnneTheAgile Dec 18 '18 at 18:52
  • 6
    Warning: macos 10.14 and later only allows control if Screen Sharing is enabled through System Preferences. – grAPPfruit Feb 19 '19 at 10:55
  • Works on Mojave as well, despite the warning. Thanks for sharing this! – jweyrich Sep 28 '20 at 14:56
  • Still works on Big Sur 11.3.1 !!! – EarlGrey May 10 '21 at 15:14
  • Worked today on my mid-2011 Mac mini running High Sierra 10.13.6. Word of warning, though - this enables Remove Management rather than Screen Sharing - and don't try to swap from one to the other through the remote GUI - oops :-) – kbro Mar 11 '22 at 11:44
45

Here is a different way, that enables screen sharing access for all current users, instead of using a single VNC password:

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

Disable it with this:

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off

This allows you to connect to the remote computer from a mac using the share screen button in Finder.

Reference: http://ss64.com/osx/kickstart.html

Iulian Onofrei
  • 285
  • 5
  • 19
  • 2
    For posterity: if you do this, you can also connect via /System/Library/CoreServices/Screen Sharing.app. – Danica May 27 '13 at 20:50
  • 1
    Note that you can (very) easily launch the Screen Sharing app using a Spotlight search – Vincent Robert Nov 07 '16 at 22:05
  • doesn't work for me on macOS Sierra 10.12 – SegFault Jul 19 '17 at 14:20
  • 1
    worked for me on macOS High Sierra 10.13.6 – Fahim Hossain Aug 20 '18 at 07:10
  • 15
    Got this response on macOS Mojave: "Warning: macos 10.14 and later only allows control if Screen Sharing is enabled through System Preferences." – toralux Aug 15 '19 at 08:26
  • Latest edit has a type in first command in "Resouces" -> "Resources", and I cannot edit just that because I'd need to fix more stuff that doesn't need to be fixed
    sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart 
     -activate -configure -access -on 
     -configure -allowAccessFor -allUsers 
     -configure -restart -agent -privs -all
    
    – FredG May 05 '21 at 02:19
  • 2
    Not working for me on 10.15.7. Once this command is run, you can connect with Screen Sharing, but the screen is black. By contrast, turning it on with the System Preferences app, you don't get that issue. – Simon Kissane Jun 30 '21 at 08:57
  • 1
    Works on 14.2.1 -- you are brilliant! – Josh Hibschman Jan 10 '24 at 04:05