Join Nostr
2026-10-25 11:16:58 UTC

BitcoinBrabant on Nostr: When you unplug your yubikey and you've already put the password in to unlock the ...

When you unplug your yubikey and you've already put the password in to unlock the yubico authenticator application keeps on running in the background and once you plug the yubi back in again it directly shows the secrets, this is a risk. To automatically close the application fully when you unplug your yubi you can do the following, so you don't have to worry it didn't close.

You can create a background script that monitors your Mac's USB ports and terminates the application when the key is missing.Step 1: Create the Shell ScriptOpen the Terminal app on your Mac.Create a script file by running:

bashnano ~/auto_quit_yubico.sh

Paste the following script into the editor:

bash#!/bin/bash
while true; do
# Check if Yubico Authenticator is running
if pgrep -x "Yubico Authenticator" > /dev/null; then
# Check if a YubiKey is plugged into the USB system
if ! ioreg -p IOUSB -l | grep -i "Yubico" > /dev/null; then
# If app is open but no YubiKey is found, quit the app
osascript -e 'quit app "Yubico Authenticator"'
fi
fi
sleep 3
done

Press Ctrl + O then Enter to save, and Ctrl + X to exit the editor.

Make the script executable by running:
bashchmod +x ~/auto_quit_yubico.sh

Step 2: Make it Run Automatically (Launchd Agent)To keep this script running quietly in the background every time you log into your Mac:
Create a launch agent configuration file:
bashnano ~/Library/LaunchAgents/com.user.yubicoquit.plist

Paste the following configuration:
xml<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://apple.com">;
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.yubicoquit</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/YOUR_USERNAME/auto_quit_yubico.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

(Note: Replace YOUR_USERNAME with your actual macOS short username).Save and exit (Ctrl + O, Enter, Ctrl + X).

Start the background service immediately:

bashlaunchctl load ~/Library/LaunchAgents/com.user.yubicoquit.plist
“

https://bitcoinbrabant.com/product/yubikey-5c-nfc/