1

So i want to know how to remotely unlock my mac via ssh so i don't have to put my password in front of people or having to make them look the other direction while i type my password. I have tried using the command on a post that is 7 months old but i get an error: "syntax error: Expected end of line but found class name. (-2741)". Any help will be appreciated, thank you in advance!

  • Better show the screen grab of your commands – FrontENG Nov 1 '16 at 3:19
1

Set the time to require a password after sleep/screensaver in System Preferences > Security & Privacy > General to "immediately".

To lock the screen enter in the ssh session:

open -a ScreenSaverEngine

To stop the screensaver (=show the login screen) and unlock your user enter

osascript -e 'tell application "system events" to keystroke return'
osascript -e 'tell application "system events" to keystroke "password"'
osascript -e 'tell application "system events" to keystroke return'

Under certain circumstances you may have to enter the password one by one or first one keystroke and then the rest:

osascript -e 'tell application "system events" to keystroke "p"'
osascript -e 'tell application "system events" to keystroke "a"'
...
osascript -e 'tell application "system events" to keystroke return'

or

osascript -e 'tell application "system events" to keystroke "p"'
osascript -e 'tell application "system events" to keystroke "assword"'
osascript -e 'tell application "system events" to keystroke return'

You must log in to answer this question.

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