KeyChain Security 命令行工具适用于 find-internet-passwords,但不适用于 find-generic-passwords
研究使用 KeyChain 的命令行工具。我可以通过安全来做很多事情;列出我的多个钥匙串,转储它们并设置默认值。 找到我的密码
阅读教程和其他帖子,我希望通过security find-generic-password test
,但我得到
安全:SecKeychainSearchCopyNext:在钥匙串中找不到指定的项目。
这在我的默认钥匙串或 login.keychain 中不起作用。但是,我可以使用 find-internet-password 命令找到列为“internet”的密码。谁能解释为什么或我做错了什么?我一直在阅读的网站是手册页和 http://blog.macromates.com/2006/钥匙串访问 shell/,
Looking into using the command line tool for KeyChain. I am able to do a lot of the things through security; listing my multiple keychains, dumping them and setting defaults. Reading through tutorials and other postings I expect to find my passwords with
security find-generic-password test
But I get
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
This won't work in my default keychain or login.keychain. However, I am able to find my passwords listed as 'internet' with find-internet-password command. Can anyone explain why or what I am doing wrong? Sites I've been reading is the man page and http://blog.macromates.com/2006/keychain-access-from-shell/,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通用密码由其服务和帐户属性标识。例如,要搜索“foo”服务的帐户“bar”的密码,请使用
-g
选项在输出末尾显示密码值。服务和帐户的组合保证唯一地标识特定密码。其他查询(注释、标签等)也是可能的,但它们可能匹配多个密码。
find-generic-password
仅显示第一个匹配项,这限制了它对于此类查询的有用性。Generic passwords are identified by their Service and Account attributes. For example, to search for a password for account "bar" of the "foo" service, use
The
-g
option displays the value of the password at the end of the output.The combination of service and account is guaranteed to uniquely identify a particular password. Other queries (comment, label, etc.) are possible, but they may match multiple passwords.
find-generic-password
displays only the first single matching item, which limits its usefulness for such queries.如果您只需要密码,更准确和最新的答案是使用
-w
而不是-g
。我见过人们使用-g
并使用 awk/perl 解析输出来获取密码字段,而这是不需要的(不再需要)。您需要做的就是:
您可以使用
find-internet-password
而不是find-generic-password
命令,具体取决于您的密码在钥匙串中的存储位置。A more accurate and up to date answer would be to use
-w
instead of-g
if you only need password. I've seen people using-g
and parsing output using awk/perl to get the password field, which is not needed (anymore).All you need to do is:
You may use
find-internet-password
instead offind-generic-password
command depending on where your password is stored in keychain.