浏览代码

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 14 年之前
父节点
当前提交
b75862d627
共有 1 个文件被更改,包括 11 次插入0 次删除
  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