Lock Your Keychain Immediately with security lock-keychain
Manually lock saved passwords so apps must re-authenticate before reading them.
Run security lock-keychain ~/Library/Keychains/login.keychain-db to lock all saved passwords right now.
01Command
Command
$ security lock-keychain ~/Library/Keychains/login.keychain-db02What it does
Once locked, nothing on the Mac can read stored passwords until the keychain is unlocked again with your login password — a strong safeguard when you step away or hand the Mac to someone. Locking affects iCloud Keychain-backed passwords too, so Safari and Mail will prompt again on next use. The matching unlock-keychain command restores access.
03Risk
!Warning: Every app that relies on saved passwords will start prompting after you lock, which can be disruptive mid-work. This is different from locking the screen — the unlocked desktop session stays open.
04Undo
Undo
$ security unlock-keychain ~/Library/Keychains/login.keychain-db05Sources
- security - keychain command line interfaceEvidence: Documents security lock-keychain and unlock-keychain for manually controlling keychain lock state.
Last verified: 2026-09-18 · Category: Security & Privacy