summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/guiscripts/keyadd10
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/guiscripts/keyadd b/bin/guiscripts/keyadd
index 4613b8f..e0a1661 100755
--- a/bin/guiscripts/keyadd
+++ b/bin/guiscripts/keyadd
@@ -31,7 +31,15 @@ notify ()
SSHFOLDER="$HOME/.ssh"
-if test -z "${key:=$1}"
+# Test if can connect to ssh-agent
+ssh-add -l > /dev/null 2>&1
+if [ $? -gt 1 ] # ignore if there are no identities
+then
+ notify "could not connect to agent."
+ exit 1
+fi
+
+if [ -z "${key:=$1}" ]
then
key="$(find "$SSHFOLDER" -iname "*.pub" |
sed "s,$SSHFOLDER/,," | # Clean