Score:0

Ubuntu Yubikey Lock Computer on Key Removal

th flag

I followed Ubuntu Auto-Lock on Yubikey USB Removal, and it works fine when in the Gnome session. However, when using Terminal e.g. "sudo echo test" and on ENTER of the password it logs me out of the Gnome session and takes me to the login screen even though i did not actually remove the key:

Here is the screensaver lock code:

#!/bin/bash 
# Double checking if the Yubikey is actually removed
if [ -z "$(lsusb | grep Yubico)" ]
then
        logger "YubiKey Removed or Changed"
        sessionids=`/bin/loginctl list-sessions | grep <userAccount> | awk '{print $1}'`
        for id in $sessionids
                do
                        logger "Locking session id:" $id
                        /bin/loginctl lock-session $id
                done
fi
CaptainCook avatar
th flag
How can i change the code to not log me out of terminal user sessions (same user as the user for the Gnome shell session) without having key removed?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.