Delete item from keychain via CLI

ThijsX
Valued Contributor
Valued Contributor

Hi,

I am having a hard time with deleting a simple value from the login keychain of the logged in user via the CLI, i have tried many commands but non of them will delete the entry, is there anyone who got the golden tip?!

See screenshot for what i am trying to delete, it is a keychain entry from a SMB network printer.
176d8455bcf0449b940b3b6ccc6dec6c

1 ACCEPTED SOLUTION

ThijsX
Valued Contributor
Valued Contributor

Hi,

Created a discussion to fast, figured it out alread. Thanks to @Chris_Hafner for his post on a discussion!
Below what worked for me.

#!/bin/sh

#Determine the currently logged in user and save their account name as the loggedInUser
loggedInUser=$( ls -l /dev/console | awk '{print $3}' )

#Delete the specified 'network password' item(s) from the logged in users keychain.
security delete-internet-password -l "Bol.com Multifunctional" /Users/$loggedInUser/Library/Keychains/login.keychain

# Set authentication method to username & password
lpadmin -p bol_com_multifunctional -o auth-info-required=username,password

exit 0

View solution in original post

1 REPLY 1

ThijsX
Valued Contributor
Valued Contributor

Hi,

Created a discussion to fast, figured it out alread. Thanks to @Chris_Hafner for his post on a discussion!
Below what worked for me.

#!/bin/sh

#Determine the currently logged in user and save their account name as the loggedInUser
loggedInUser=$( ls -l /dev/console | awk '{print $3}' )

#Delete the specified 'network password' item(s) from the logged in users keychain.
security delete-internet-password -l "Bol.com Multifunctional" /Users/$loggedInUser/Library/Keychains/login.keychain

# Set authentication method to username & password
lpadmin -p bol_com_multifunctional -o auth-info-required=username,password

exit 0