Last active
September 15, 2015 18:34
-
-
Save bkemper/f3feea7dcbf4b513071e to your computer and use it in GitHub Desktop.
Key management with OS X Keychain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Too often developers leave keys in unencrypted files (e.g. bash_profile). | |
# The following are instructions to show how easy it is to create a new keychain | |
# for your project and fetch the keys. | |
# Create a keychain for your project | |
$ security create-keychain <your-project-name>.keychain | |
# Add keychain to search list (optional) | |
# | |
# @note The -s argument sets the list. If you have other keychains, you must | |
# include them. | |
# @see http://stackoverflow.com/a/22234506 | |
# @todo Find a way to append a new keychain to the list | |
$ security list-keychains -d <your-username> -s login.keychain <your-project-name>.keychain | |
# Save your secret | |
# | |
# @note This command should be run in a shell without history. | |
# @see http://stackoverflow.com/a/8473732 | |
$ security add-generic-password -a <your-username> \ | |
-s <your-secret-name> \ | |
-w "password with spaces" \ | |
<your-project-name>.keychain | |
# Fetch your secret | |
$ security find-generic-password -s <your-secret-name> -w <your-project-name>.keychain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment