Lock Your Keychain Immediately with security lock-keychain

Manually lock saved passwords so apps must re-authenticate before reading them.

macOSlockKeychainsecurityMedium risk
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-db

02What 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

RiskMedium risk
!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-db

05Sources

Last verified: 2026-09-18 · Category: Security & Privacy

06Related solutions