summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-07-04 15:39:44 +0200
committerAnton Khirnov <anton@khirnov.net>2022-07-04 15:42:19 +0200
commit18dbadf1a02b797acb4a99b2670b022462664dd3 (patch)
tree70fbe2b3e7cd0eee845c05eb860b098fb47fd339
parentcbebddb1e856c74887cefeae03566b73fb19c1f3 (diff)
Add more verbosity to FIDO key loading/cleaning
-rwxr-xr-xbin/ssh_sk_add8
-rwxr-xr-xbin/ssh_sk_clean7
-rw-r--r--desktop.conf.yaml1
-rw-r--r--dotfiles/Xsession3
4 files changed, 16 insertions, 3 deletions
diff --git a/bin/ssh_sk_add b/bin/ssh_sk_add
new file mode 100755
index 0000000..24079e4
--- /dev/null
+++ b/bin/ssh_sk_add
@@ -0,0 +1,8 @@
+#!/bin/sh
+# load resident keys from a FIDO authenticator to the SSH agent
+output=$(ssh-add -K 2>&1)
+if [ $? -eq 0 ]; then
+ notify-send -u low "FIDO keys loaded" "${output}"
+else
+ notify-send -u critical "Error adding FIDO2 keys to SSH agent" "${err_output}"
+fi
diff --git a/bin/ssh_sk_clean b/bin/ssh_sk_clean
index 1f32658..22edc24 100755
--- a/bin/ssh_sk_clean
+++ b/bin/ssh_sk_clean
@@ -2,5 +2,10 @@
# remove all FIDO keys from the SSH agent
fido_keys=$(ssh-add -L|grep '^sk-')
if [ -n "${fido_keys}" ]; then
- echo "${fido_keys}" | ssh-add -d /dev/stdin
+ output=$(echo "${fido_keys}" | ssh-add -d /dev/stdin 2>&1)
+ if [ $? -eq 0 ]; then
+ notify-send -u low "FIDO keys cleaned"
+ else
+ notify-send -u critical "FIDO keys not cleaned" "${output}"
+ fi
fi
diff --git a/desktop.conf.yaml b/desktop.conf.yaml
index 717384a..8fb98d8 100644
--- a/desktop.conf.yaml
+++ b/desktop.conf.yaml
@@ -10,6 +10,7 @@
~/.local/bin/brightness_monitor: bin/brightness_monitor
~/.local/bin/random_wallpaper: bin/random_wallpaper
~/.local/bin/randr_output_toggle: bin/randr_output_toggle
+ ~/.local/bin/ssh_sk_add: bin/ssh_sk_add
~/.local/bin/ssh_sk_clean: bin/ssh_sk_clean
~/.local/bin/udev_match: bin/udev_match
~/.local/bin/zathura: bin/zathura_wrapper
diff --git a/dotfiles/Xsession b/dotfiles/Xsession
index 3d2a716..473e1b8 100644
--- a/dotfiles/Xsession
+++ b/dotfiles/Xsession
@@ -17,8 +17,7 @@ run_if_exists parcellite
# on FIDO HW key add/remove, update the SSH agent
udev_match --subsystem=hidraw --match=ACTION=remove --match=ID_FIDO_TOKEN=1 ssh_sk_clean &
-udev_match --subsystem=hidraw --match=ACTION=add --match=ID_FIDO_TOKEN=1 \
- "ssh-add -K || notify-send -u critical 'Error adding FIDO2 keys to SSH agent' 'Wrong PIN?'" &
+udev_match --subsystem=hidraw --match=ACTION=add --match=ID_FIDO_TOKEN=1 ssh_sk_add &
# show notifications on brightness changes
for d in /sys/class/backlight/*; do