From 454f5f152c9db76d3d43ce88ac11b81025564a08 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 25 Mar 2019 21:12:11 -0300 Subject: Adds askpass support into ssh-agent-loadkey --- ssh-agent-loadkey | 15 +++++++++++---- ssh-agent-loadkey-menu | 8 +++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ssh-agent-loadkey b/ssh-agent-loadkey index e02bd1f..1207a05 100755 --- a/ssh-agent-loadkey +++ b/ssh-agent-loadkey @@ -5,8 +5,10 @@ # Parameters BASENAME="`basename $0`" +KEYS="$HOME/.ssh/keys" TYPE="$1" HANDLE="$2" +KEY="$KEYS/$TYPE/$HANDLE" # Check if [ -z "$HANDLE" ]; then @@ -15,10 +17,15 @@ if [ -z "$HANDLE" ]; then echo "" ( cd $HOME/.ssh/keys && find -name '*.pub' ) | grep -v decomissioned | sed -e 's/^/\t/' exit 1 -elif [ ! -e "$HOME/.ssh/keys/$TYPE/$HANDLE" ]; then - echo "$BASENAME: file not found: $HOME/.ssh/keys/$TYPE/$HANDLE" +elif [ ! -e "$KEY" ]; then + echo "$BASENAME: file not found: $KEY" exit 1 fi -# Dispatch -ssh-add $HOME/.ssh/keys/$TYPE/$HANDLE +# Check if the selected option has a custom procedure (monkeysphere, keyringer, etc) +if [ -x "$KEY.askpass" ]; then + # SSH-ADD(1) says: "Note that on some machines it may be necessary to redirect the input from /dev/null to make this work". + SSH_ASKPASS="$KEYS.askpass" ssh-add $KEY < /dev/null +else + ssh-add $KEY +fi diff --git a/ssh-agent-loadkey-menu b/ssh-agent-loadkey-menu index 6029729..7640032 100755 --- a/ssh-agent-loadkey-menu +++ b/ssh-agent-loadkey-menu @@ -59,12 +59,14 @@ function __chooser { # Load a key function __load { + KEY="$KEYS/$1" + # Check if the selected option has a custom procedure (monkeysphere, keyringer, etc) - if [ -x "$KEYS/$1.askpass" ]; then + if [ -x "$KEY.askpass" ]; then # SSH-ADD(1) says: "Note that on some machines it may be necessary to redirect the input from /dev/null to make this work". - SSH_ASKPASS="$KEYS/$1.askpass" ssh-add $HOME/.ssh/keys/$1 < /dev/null + SSH_ASKPASS="$KEYS.askpass" ssh-add $KEY < /dev/null else - ssh-add $HOME/.ssh/keys/$1 + ssh-add $KEY fi } -- cgit v1.2.3