#### Using the OS X Keychain to store and retrieve passwords
##### Adding secrete to toolchain
-
By using GUI (“Keychain-Access”)
- Select File->New Password Item (cmd+N)
- Make sure Keychain item name is distinct —>
service-namein command line - Account name —>
USERin command line, it is$whoami, orecho ${USER}
-
Command line using security command
- Help:
security add-generic-password -h -
Add command:
add-generic-password$ security add-generic-password -a ${USER} -s <service-name> -wEnter password on prompt,
-
Update password if already exists :
-Uflag$ security add-generic-password -a ${USER} -s <service-name> -w -U -
Delete password:
security delete-generic-password -h$ security delete-generic-password -a ${USER} -s <service-name> - Retrieve Password:
$ security find-generic-password -h - Retrieve Password in bash script or commandline:
$ security find-generic-password -a ${USER} -s <service-name> -w OR $ security find-generic-password -l <service-name> -g 2>&1 | grep '^password' | sed -e 's/^password: "//' -e 's/"$//'
- Help: