Keychain Access from a Shell.sh Script
January 17th, 2007
Here’s a useful snippet to enable you to securely store passwords in OS X’s keychain and use them in a shell scripts.
#!/bin/bash PASSWORD=`exec osascript <<EOF | tr "\r" "\n" (* To use the Keychain to store the admin password then Open /Applications/Utilities/Keychain Access.app Add a new keychain called "TM" Add a Key with the name "test" and store your password in it. I'd recommend learning how keychains work then tailoring the process to your security needs. *) EOF` echo "$PASSWORD" exit 0;
Update: As of Leopard it is now possible to do this via the command line tool security





Leave a Reply