从钥匙串里删除已保存的密码
用 security delete-generic-password 把钥匙串里过期的应用或服务密码彻底删除。
运行 `security delete-generic-password -s "服务名称"` 即可永久删除该密码条目。
01命令
命令
$ security delete-generic-password -s "MyOldService"02作用说明
效果等同于在"钥匙串访问"里点删除,可以按服务名(-s)、账户(-a)或标签(-l)来定位条目。删除浏览器保存的网站密码要用 `delete-internet-password`。注意如果创建它的软件还在自动保存密码,之后可能会重新写入,必要时把那个软件的保存密码功能也关掉。
03风险
!注意: 删除立即生效且无法恢复——执行前先确认服务名称没写错。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- security — administer Keychains and key items (macOS man page)依据: Documents `security delete-generic-password [-s service]` and `delete-internet-password` to remove items from a keychain.
- Keychain data protection on Mac依据: Describes how the keychain stores passwords and credentials as protected items that can be managed and removed.
最后验证: 2026-09-18 · 分类: 安全与隐私