delete local keychain

jalcorn
Contributor II

so for the life of me i can't sort this out. The below works great locally but can't make it work when i push it out via jamf. Save me guys.

security delete-internet-password -s thingiwanttokill

2 REPLIES 2

mm2270
Legendary Contributor III

Same issue that comes up daily, maybe even hourly, on this site. It's because most everything run from a jamf policy runs as root. The command you have works fine when in Terminal because you are running it as you, meaning it knows which keychain to look in for the item to delete. Unless you tell it to either run the security command as the user (probably the best approach) or at the very least direct security at the current user's login.keychain, it won't work, because it's actually looking in /private/var/root/Library/Keychains/ for the item. Not gonna be in there.

jalcorn
Contributor II

@mm2270

So im looking for something like this?

loggedInUser=$(stat -f%Sgu /dev/console) security delete-internet-password -s /Users/$loggedInUser/Library/Keychains/thing.chathamfinancial.com