]> gitweb.fluxo.info Git - utils-ssh.git/commitdiff
Adds askpass support into ssh-agent-loadkey
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 26 Mar 2019 00:12:11 +0000 (21:12 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 26 Mar 2019 00:12:11 +0000 (21:12 -0300)
ssh-agent-loadkey
ssh-agent-loadkey-menu

index e02bd1f44ce434d87dc28a95c00bd1d4a48f8d77..1207a05686a25961b244c307ad975a23fdb872c4 100755 (executable)
@@ -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
index 6029729682ded56a8443a0c10a3ec1d809969ad0..7640032c2d89171e52fc943aba8e15cee16bf0a9 100755 (executable)
@@ -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
 }