Require Password after Screen Saver – Command Line

To ensure that your machine is secure, enable a password prompt by typing the following into Terminal

defaults write com.apple.screensaver askForPassword -int 1

To set a delay on it before it becomes active, type the following into Terminal

defaults write com.apple.screensaver askForPasswordDelay -int 300

The delay is in seconds, so the command above sets it to 300 seconds, or 5 minutes