I want to be able to unlock screen, or login to physical user while I'm connected with ssh connection. I know this might be unsafe etc. However that's ok for me at the moment. What options do I have to do this?

  • What exactly do you want to achieve? The machine is in the login screen and you want to login (create GUI session) as a user using SSH connection? – Mateusz Szlosek Mar 7 '18 at 9:13
  • I'm not sure to understand what you want. Is teamviewer or remote desktop like you want to do ? – Chris Mar 7 '18 at 9:14
  • Machine is either of this two states: 1)Login screen. 2)Lock screen. I want to unlock it but either by any program or terminal. In other words I'm not physically there and need to write some kind of credential provider, I might have user credentials already saved. This program will provide user and password to system which will unlock physical screen – Shortman Mar 7 '18 at 9:14
  • For example, in case of Linux I could use loginctl unlock-session c1 from ssh connection, if user "Tim" is running under c1 session and he has locked his screen this command would unlock session c1 – Shortman Mar 7 '18 at 9:20
  • I don't know any program that does this, but I know you can create your own SecurityAgentPlugin from: developer.apple.com/library/content/technotes/tn2228/… The info is rather old, because etc/authorization is moved to the security authorizationdb -> derflounder.wordpress.com/2014/02/16/… – Mateusz Szlosek Mar 7 '18 at 9:21

The duplicate link I added has some really good Apple Script options.

$ osascript -e 'tell application "System Events"
> keystroke "verysecurepassword"
> key code 36
> end tell'

I might also suggest using LockScreen. It's a hidden application that comes preinstalled and is protected by System Integrity protection. It will put a lock icon on the screen, lock the keyboard and mouse, and freeze the Touch Bar (Sounds malicious, right?).

  1. System Preferences > Security & Privacy > Uncheck "Require Password...."

  2. To lock the Mac use

$ /System/Library/CoreServices/RemoteManagement/AppleVNCServer.bundle/Contents/Support/LockScreen.app/Contents/MacOS/LockScreen
  1. To unlock the Mac use (non tested but should work)
    $ killall LockScreen
| improve this answer | |

I would be shocked if this existed since who would want their locked machine to exit the security without doing what is expected - TouchID or typing the correct password.

For code and API - check out our partner site Stack Overflow - the API to lock a screen is documented there and you might find official Apple developer API and SDK at https://developer.apple.com

| improve this answer | |

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