aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2019-03-25 21:12:11 -0300
committerSilvio Rhatto <rhatto@riseup.net>2019-03-25 21:12:11 -0300
commit454f5f152c9db76d3d43ce88ac11b81025564a08 (patch)
tree8434421f54921e9f98627a04b13e9531d58fa60a
parent74e28743f7021e3db39eaa3d81afa9eaff710ad6 (diff)
downloadutils-ssh-454f5f152c9db76d3d43ce88ac11b81025564a08.tar.gz
utils-ssh-454f5f152c9db76d3d43ce88ac11b81025564a08.tar.bz2
Adds askpass support into ssh-agent-loadkey
-rwxr-xr-xssh-agent-loadkey15
-rwxr-xr-xssh-agent-loadkey-menu8
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
}