31

Apple Remote Desktop has a "curtain" feature that a remote client can use to lock the screen of the Mac that's being remotely controlled. I use this when I connect to my work Mac from my home Mac. My work Mac's screen shows a big lock icon and a message while I'm remotely controlling it from my home Mac using Apple Remote Desktop (ARD).

Unfortunately, there's a bug of some kind that causes the remote Mac's screen to stay locked, even after I've disconnected from it. (Latest ARD and OS X 10.8.2 on both machines.) When this happens, I come in to work the next day to find the big lock icon and message on my Mac's screen. Despite now being physically present in front of the Mac, I can't find a way to unlock the screen.

I usually try ssh-ing into the Mac from another machine and killing processes. I've tried killing the ARDAgent process, the screen lock process (I can't recall the name), and anything else I can find with "ard" or "remote" in the process name. None of these things seem to unlock the screen. Eventually, I resort to using osascript -e ... to tell all my running applications to gracefully quit, then I run shutdown -r now to reboot the machine.

My question: is there a way to successfully unlock a Mac that's stuck on the ARD lock screen, using ssh or otherwise?


One way to reproduce this: Log in to the target Mac with Remote Desktop, initiate Curtain mode, and then after finishing whatever work was to be done, log out the user on the target Mac while still under Curtain mode. This will leave the Mac inaccessible to the Remote Desktop app and even a physical user of the computer, with the large lock icon still on the screen of the target Mac.

I'm not sure what I'm doing to trigger this situation, but I'm definitely not logging out. Either way, it seems like the solution should be the same.

3
  • 1
    Without answering your question directly: Is there a specific reason why you are using ARD instead of Screen Sharing?
    – nohillside
    Sep 24, 2012 at 14:47
  • 1
    I'm using ARD because Screen Sharing does not have this "curtain" feature, and I don't want people at work to be able to see and access my Mac when I'm not there. Sep 24, 2012 at 15:39
  • I would have suggested using normal screen sharing and the Virtual display rather than the Hardware one, but as per an outstanding question of my own, it seems to have disappeared under 10.8 as an option when using 10.8 as the client...
    – stuffe
    Sep 26, 2012 at 22:24

10 Answers 10

12
+50

I don't have a Mac with ARD to test this, but this sunshine-ard utility suggests it can fix the problem. From a quick glance at the source code, it just sends a CFNotificationCenter message to quit the curtain mode.

I'm not sure if there's a way to hook in to the ARD logout process to have this run every time you disconnect your session, but at the very least you could run it via SSH as necessary.

12
  • 1
    That looks promising! I'll try it next time I can reproduce the bug. Sep 26, 2012 at 23:25
  • 1
    Despite many attempts, I still haven't been able to reproduce my bug. Since the bounty expires tomorrow, I'm going to accept this answer based on the assumption that it will work. Oct 2, 2012 at 13:48
  • 1
    I too have not been able to reproduce it, but I did find some documentation on how to use AppleScript to unlock screens and will post that as a separate answer even though this one seems like the best place for the bounty for the code level detail on the inner workings of CFNotificationCenter.
    – bmike
    Oct 2, 2012 at 15:23
  • 3
    This worked perfectly. If in any case some people still run into this issue (like me), you can find the code on github.com/mattlavine/sunshine-ard.
    – frbl
    Jul 25, 2016 at 19:41
  • 3
    I tried this on my mac running Mojave, and it didnt work, fyi.
    – Brad Parks
    Apr 8, 2019 at 17:43
10

This fastest solution I have found is to make a SSH connection to a admin account on the remote computer that is locked.

ssh "adminuser"@ip.address/or.computername

Type: ps -ax | grep AppleVNCServer

You want the line that reads something like

/System/Library/CoreServices/RemoteManagement/AppleVNCServer.bundle/Contents/Support/LockScreen.app/Contents/MacOS/LockScreen -session 256 -msgHex 

Jot down the PID that is to the left of this.

then enter:

sudo kill -9 "PID" 

This will force restart the lock screen and make it available again.

I know this is like the post above just explained. It is also done on two 10.8.2 machines running ARD 3.6.1.

3
  • This worked for me on El Cap this afternoon (and saved the day). Thanks!
    – Mark
    Sep 10, 2016 at 0:10
  • 2
    Tried this on Mojave, no luck.
    – Noah
    Sep 29, 2018 at 11:46
  • 1
    Just tested on Catalina (10.15.4) and ARD (3.9.3). Saved me a reboot (and a headache - ARD is extremely buggy)
    – teopeurt
    May 23, 2020 at 17:33
5

For what it's worth, this is a known bug in ARD and has apparently been around for a while. This Apple KB has an article about it, but no suggestion on how to fix it. http://support.apple.com/kb/TS2401

Key part of the document:

If you use Remote Desktop to take control of a client using Curtain mode, then log in or log out on the remote client, the control session will end and you will not be able to take control of the computer again until it is restarted. This occurs on client running Mac OS X v10.5 or later, and will also occur if you Lock the Screen of the client before taking Control.

Resolution

Before logging out, close any windows with sensitive information, end the control session (and Unlock Screen if necessary). Do not log out on the remote client while controlling it in Curtain mode.

4

If you're on El Capitan, the above instructions involving killing the lock screen won't work. There's some process that keeps starting it up and I was unable to find it using launchctl list. I also tried to shut down ARD via my ssh login but that didn't work either. Apparently the LockScreen.app and ARD are decoupled processes or something. I wound up having to do a shutdown -r now to force a reboot. I'm pretty pissed that Apple hasn't fixed this bug or provided a workaround that, you know, actually works AFTER the fact.

2
  • Indeed, I have this same problem. I tried killing the lockscreen and other daemons running, but no luck. I'll look for different solutions and post them here if I find any.
    – frbl
    Apr 14, 2016 at 20:46
  • Any luck finding a solution?
    – tmm1
    Apr 28, 2019 at 19:22
3

Apple provides an example of how to script the lock screen in Chapter 9 of the ARD Admin Guide.

As you already have osascript access, I would send the unlock command.

-- Start commanding the local copy of Remote Desktop
tell application "Remote Desktop"
  -- decide which list to perform this on, in this case it's called
     "WorkMac"
  set these_computers to computer list "WorkMac"
  -- unlock the screen when finished
  execute (make new unlock screen task) on these_computers
end tell 
2

OK, I cannot comment on using ARD, I don't have it, but this may be a suitable workaround, at least in the meantime.

Using normal screen sharing you have the option of using either the hardware display, or the virtual one. This was an easy thing to use on 10.7 but it's been obfuscated rather on 10.8 and the menu item command to switch displays is gone.

To use the virtual display, here's what you need to do. Firstly, have another user to your normal one that has the relevant screen sharing options allowed, then login:

  • If no one is logged into the target machine, you will always get the Hardware display showing the normal login screen
  • If your the user you try to login as is already logged in, then it will always switch to that user and use the hardware display
  • If you login with another user who is not already logged in at the hardware display, you get the following message and the ability to use the virtual display which results in being able to do whatever you like without changing the main screen and with no possibility of anyone being able to watch it

enter image description here

This isn't perfect, you need to ensure your secondary user has the relevant access rights to the files and such that you may need to access, or you may have to adopt the awkward practice of leaving your secondary (or "dummy") user logged in when you leave the desk allowing you to use your primary ID over screen sharing, but it may help.

2

I can't reproduce your exact setup as I don't currently have a second machine running 10.8.2 and 3.6.1, but here's what I tried:

From my 10.8.2/3.6.1 admin Mac I locked the screen on my 10.6.8 client, logged out of the client and reproduced the screen locking glitch. I was disconnected from my ARD session and the client remained with the lock screen icon. I ssh'd in to the client and after trying to get some love from 'kickstart' I ran launchctl list which revealed a 'LockScreen' job. Killing it without issuing a signal had no effect but sending it a -9 removed the lock icon from the screen and after a few seconds the loginwindow loaded. You'll have to try it under your conditions in order to verify this same technique works on a locked 10.8.2/3.6.1 machine and when the issue is caused by something other than the user logging out.

2
  • 1
    I've definitely killed that process and then seen the lock remain on the screen. I will try it again next time I reproduce the bug, just to be sure. Sep 26, 2012 at 23:12
  • Good info on a troubleshooting avenue, but killing the process doesn't work. See my applescript to send the unlock programatically.
    – bmike
    Mar 28, 2014 at 12:56
2

Make a simple shell script like this:

#!/bin/sh
# Make ARD sane again
LOCK=`ps -ax | grep LockScreen.app | awk {'print $1'}`
ARD=`ps -ax | grep AppleVNCServer | awk {'print $1'}`
sudo kill -9 $LOCK $ARD
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -restart -agent
1
  • Not working on mojave
    – karlacio
    Nov 4, 2021 at 9:57
0

In the Remote Desktop app, open the system list and highlight a remote machine that shows a status of "Locked Screen." Pull down the Interact menu and choose "Unlock Screen..."

You'll immediately see the system's status change from "Locked Screen" to "Available." You can then initiate a new curtain mode connection.

2
  • Which Remote Desktop app is this?
    – tmm1
    Apr 28, 2019 at 19:22
  • Apple Remote Desktop.App v 3.9.
    – user190196
    Apr 30, 2019 at 5:19
0

What worked for me is:

  1. Connect via ssh user@host
  2. Run sudo pkill loginwindow

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .