From 67907b8ab65573c2ca6b3805c6bb43fc0850c8a3 Mon Sep 17 00:00:00 2001 From: Marco Thomas Date: Tue, 31 Mar 2026 17:41:03 +0200 Subject: [PATCH] ssh-agent: nuke agent on lock --- README.md | 7 ++++++- remove-ssh.bash | 8 ++++++++ remove-ssh.service | 10 ++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 remove-ssh.bash create mode 100644 remove-ssh.service diff --git a/README.md b/README.md index 285b88a..1711c7d 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,12 @@ Use ./stow.sh --unstow to remove configuration - gamemode configuration: - renice=10 - diff for .ohmyzsh via patch files - +- ssh-agent: + - ohmyzsh patch for agent location + - `mv $HOME/.dots/remove-ssh.service ~/.config/systemd/user/remove-ssh.service` + - `systemctl --user start remove-ssh` + - `systemctl --user enable remove-ssh` + ## Software ### Basics diff --git a/remove-ssh.bash b/remove-ssh.bash new file mode 100755 index 0000000..8cf854c --- /dev/null +++ b/remove-ssh.bash @@ -0,0 +1,8 @@ +#!/bin/bash +dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | + while read x; do + case "$x" in + *"boolean true"*) echo SCREEN_LOCKED; ssh-add -D;; + *"boolean false"*) echo SCREEN_UNLOCKED;; + esac + done diff --git a/remove-ssh.service b/remove-ssh.service new file mode 100644 index 0000000..2f62916 --- /dev/null +++ b/remove-ssh.service @@ -0,0 +1,10 @@ +[Unit] +Description=Remove SSH keys on lock + +[Service] +Type=simple +Environment=SSH_AUTH_SOCK=/tmp/agent.sock +ExecStart=%h/.dots/remove-ssh.bash + +[Install] +WantedBy=default.target