Kaynağa Gözat

add check to run ssh-add if identity not loaded

I mentioned we could rely on OS prompts to add identities, but it proved to be
more convenient to just ask at the start of any terminal session, rather than
wait for the first ssh attempt.

Also, this means my tmuxinator setups won't have the chance to ask for the
passphrase.
Weiyi Lou 13 yıl önce
ebeveyn
işleme
b75862d627
1 değiştirilmiş dosya ile 11 ekleme ve 0 silme
  1. 11 0
      zsh/omz-custom/ssh-add.zsh

+ 11 - 0
zsh/omz-custom/ssh-add.zsh

@@ -0,0 +1,11 @@
+# Add the first user identity if the local ssh-agent doesn't already have
+# something.
+#
+# Silence error output for when we're sshing to a machine that we don't want to
+# use ssh-agent forwarding for.
+#
+# This works well when there is only one identity. Don't know what
+# would happen if a person had more than one private key to use.
+if [[ `ssh-add -l 2> /dev/null` != *id_?sa* ]]; then
+  ssh-add 2> /dev/null
+fi