I have been trying to learn to control my computer through command-line, and keychain access is what I am trying now. I have been using the security command, and attempting to get my wifi password (I know it of course, but getting it through terminal is the challenge). From what I have read on other Stack Exchange pages (like this one) and this often referenced site,

security find-generic-password -a Netgear25 -s Airport -g

should come up with a list of information, including the password. But there is no output at all. So the 'result' is:

Host:~ Batman$ security find-generic-password -a Netgear25 -s Airport -g
Host:~ Batman$


security 2>&1 >/dev/null find-generic-password -a Netgear25 -s Airport -g security 

does the same thing, no result. What am I going wrong?


I think I should clarify - I am doing this remotely for a challenge, and obviously when I do it on the computer itself it comes up with the Authorisation Dialog Box. Remotely though, the dialog box won't come up. So the real question is how to authenticate it remotely (using sudo also comes up with no result).

  • @klanomath read my comment on steviethecat's answer – DJpotato Jun 16 '16 at 10:28

I have not scored enough points (yet) to mark this as a duplicate, but on How can I access the keychain remotely from the command line? you will find the solution to help you out here.

In short: Add "security" to the "Access Control", re-login and run security unlock-keychain ~/Library/Keychains/login.keychain before running security find-generic-password.

  • I did see that, but I would prefer not to permanently allow access to the 'security' command - if anyone were to gain access to my computer, then they would have access to it as well. So I could use this function, but I'd prefer it to simply require my password on request through terminal than ALWAYS allow access, at any time. (Since this answer is not given on the other page, it is not a duplicate). – DJpotato Jun 16 '16 at 10:25
  • Well, you still have to unlock the keychain every time you remotely login (security unlock-keychain ~/Library/Keychains/login.keychain). That does require your password. Just tested it, every time I login remotely, I first need to unlock the keychain, before being able to search the keychain. To prevent a hacker with physical access to your computer to access the keychain, a screensaver with password protection might slow them down. – steviethecat Jun 16 '16 at 11:17

Not the answer you're looking for? Browse other questions tagged .