How to unlock my mac remotely? 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!
Set the time to require a password after sleep/screensaver in System Preferences > Security &amp; 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'