Last active
March 2, 2016 08:42
-
-
Save mhogerheijde/3402bfa8a5d5208179b1 to your computer and use it in GitHub Desktop.
Automatically lock current session when your Yubikey is removed (or when any other event happens).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
log="/var/log/yubilock.log" | |
#yubimap="/etc/sysconfig/yubikeys" | |
userid=`ps auxn | grep -v root | grep gnome-session | head -n 1 | awk '{print $1}'` | |
user=`id -nu $userid` | |
sessionids=`/bin/loginctl list-sessions | grep ${user} | awk '{print $1}'` | |
for id in $sessionids; do | |
echo "$(date) [SCREENLOCK] $user $id '$0' '$1'" >> ${log} | |
/bin/loginctl lock-session $id | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment