I want to configure my laptop to clear all my SSH keys from the authentication agent when I close the lid of my laptop.
Clearing the keys can be done by running
ssh-add -D. Running a script when closing the lid can be achieved by adding the script to
However, when I add the command
su work -c "ssh-add -D" to a script in the directory, I get the error message:
Could not open a connection to your authentication agent.
How can the command be properly run from a script that is being run as root?