sh ssh-pass:使用密码存储中的密码短语向您的代理添加SSH密钥,无需剪贴板

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh ssh-pass:使用密码存储中的密码短语向您的代理添加SSH密钥,无需剪贴板相关的知识,希望对你有一定的参考价值。

#!/bin/bash

#Add specified SSH keys to the SSH Agent, using SSH_ASKPASS to retrieve
#each key's passphrase from the Unix password store (pass).
#This relies upon the keys having the same names in both your key directory
#and your password store.

if [[ -z ${1} ]]; then
  echo "$(basename ${0}): no SSH key specified" 1>&2
  exit 1;
fi

KEY_DIR=${HOME}/key
export DISPLAY=dummy

for KEY in ${@}; do
  export SSH_ASKPASS=$(mktemp -t ssh-askpass)
  cat > ${SSH_ASKPASS} << EOF
#!/bin/sh
pass ${KEY}|head -1
EOF
  chmod +x ${SSH_ASKPASS}
  ssh-add ${KEY_DIR}/${KEY} < /dev/null
  rm ${SSH_ASKPASS}
done

以上是关于sh ssh-pass:使用密码存储中的密码短语向您的代理添加SSH密钥,无需剪贴板的主要内容,如果未能解决你的问题,请参考以下文章