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 考虑使用 KeyChain 的命令行工具。我能够通过安全做很多事情;列出我的多个钥匙串,转储它们并设置默认值。通过阅读教程和其他帖子,我希望找到我的密码
security find-generic-password test
But I get 但是我明白了
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain. security:SecKeychainSearchCopyNext:在钥匙串中找不到指定的项目。
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/, 这在我的默认钥匙串或login.keychain中不起作用。但是,我能够使用 find-internet-password 命令找到我的密码列为“internet”。谁能解释一下我为什么或做错了什么?我一直在阅读的网站是手册页和 http://blog.macromates.com/2006/keychain-access-from-shell/,
One minor issue I ran into with find-generic-password: if the service name (-s parameter) contains a period ('.') ('example.com', for example), I can run add-generic-password successfully but can't find the value with find-generic-password. – John McCarthy
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
security find-generic-password -a foo -s bar -g
解释
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. 服务和帐户的组合保证唯一标识特定密码。其他查询(注释、标签等)是可能的,但它们可能与多个密码匹配。仅显示第一个匹配项,这限制了其对此类查询的有用性。
What is the "Service" attribute? I don't see that label anywhere in the Keychain Access app on macOS Mojave 10.14.4. The metadata I see are "Name", "Kind", "Account", "Where", and "Comments". (I tried the obvious guess here, "Name", but that does not work.) – robenkleene罗本克林
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: 一个更准确和最新的答案是使用而不是只需要密码。我见过人们使用 awk/perl 使用和解析输出来获取密码字段,这(不再)需要了。 您需要做的就是:
security find-generic-password -a foo -s bar -w
解释
You may use 您可以使用find-internet-password instead of find-generic-password command depending on where your password is stored in keychain. 您可以使用代替命令,具体取决于密码在钥匙串中的存储位置。
I am trying to sign an iPhone app for publishing, so I am following the instructions to do so. Anyhow, when creating my Certificate Signing Request I get this error from Keychain Access: "A default keychain could not be found"我正在尝试对 iPhone 应用程序进行签名以进行发布,因此我正在按照说明进行操作。无论如何,在创建我的证书签名请求时,我从钥匙串访问中收到此错误:“找不到默认钥匙串”
I found no help on Google concerning this issue - can anybody help?我在谷歌上没有找到关于这个问题的帮助 - 有人可以帮忙吗?
Sounds like you're missing your login.keychain. Either that, or you somehow un-set it as default. Look at your Keychains list in Keychain Access (View->Show Keychains). Do you have "login"? And is it bold? If either of those answers was "no", that's your problem. If you don't have a login keychain, go ahead and create one (File->New Keychain). If you don't have a bolded keychain, right-click your "login" keychain and there should be a menu item 'Make Keychain "login" Default'.听起来你错过了你的login.keychain。要么是这样,要么您以某种方式将其取消设置为默认值。在“钥匙串访问”(查看->显示钥匙串)中查看您的钥匙串列表。你有“登录”吗?它大胆吗?如果这些答案中的任何一个是“否”,那就是你的问题。如果您没有登录钥匙串,请继续创建一个(文件>新钥匙串)。如果您没有粗体钥匙串,请右键单击您的“登录”钥匙串,应该会有一个菜单项“将钥匙串”设为默认“。
You can use security command in mac您可以在 mac 中使用安全命令
security list-keychains # print all the keychains
security default-keychain -s "<printed keychain using above command>"
eg: security default-keychain "Users/myname/Library/Keychain/login-db"解释
I had a problem with I create another keychain as the default keychain I wanted to delete that keychain and make the login keychain as default keychain. You can also use我在创建另一个钥匙串作为默认钥匙串时遇到了问题,我想删除该钥匙串并将登录钥匙串设置为默认钥匙串。您还可以使用
security delete-keychain "keychain name"# to delete the keychain解释
Open Keychain and goto Keychain Access -> 'KeyChain First Aid'. Apply check on REPAIR radio button and enter Admin password in password field and click on START button. System will repair the keychain and then create certificate.打开钥匙串并转到钥匙串访问 ->“钥匙串急救”。应用检查“修复”单选按钮,然后在密码字段中输入管理员密码,然后单击“开始”按钮。系统将修复钥匙串,然后创建证书。
On Catalina OS: You can blow away your default keychain and create a new one by clicking on Keychain Access>Preferences>[check Reset My Default Keychain]在Catalina OS上:你可以通过点击钥匙串访问>首选项>[检查重置我的默认钥匙串]来取消你的默认钥匙串并创建一个新的钥匙串– John StackCommentedDec 20, 2019 at 15:14
One minor issue I ran into with find-generic-password: if the service name (-s parameter) contains a period ('.') ('example.com', for example), I can run add-generic-password successfully but can't find the value with find-generic-password. – John McCarthy
Commented Apr 19, 2022 at 22:17