Deleting password from Keychain in terminal

I'm having trouble deleting the github credentials from Keychain Access. Keychain Access just freezes everytime I try. Is there a command to force deletion of an item in the Keychain from the terminal?


Solution 1:

You may first try to find the credentials (or better the blob):

security find-internet-password -l "github.com"  /Users/user_name/Library/Keychains/login.keychain

Then delete them with:

security delete-internet-password -l "github.com"  /Users/user_name/Library/Keychains/login.keychain

If you have several github.com items you have to repeat this. Create a backup of your login.keychain (or better the whole Keychain folder) before proceeding.