Skip to main content
Solved

Delete item from keychain via CLI

  • September 28, 2017
  • 1 reply
  • 0 views

ThijsX
Forum|alt.badge.img+19

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.

Best answer by ThijsX

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 original
Did this topic help you find an answer to your question?

1 reply

ThijsX
Forum|alt.badge.img+19
  • Author
  • Employee
  • 369 replies
  • Answer
  • September 28, 2017

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

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings