如何在 bash 脚本中使用 git fetch/pull 提供密码。 我真的需要在 bash 脚本中完成它,而不是使用 ssh-add 或类似的东西。 可能吗?
最佳答案
我尝试了 ssh-agent 和 SSH_ASKPASS 的解决方案,但没有任何效果,然后我找到了使用 http://expect.sourceforge.net/ 的解决方案
示例(在 shell 中执行):
pass="passwod"
/usr/bin/expect <<EOD
spawn git fetch origin $BRANCH
expect "Enter passphrase for key '/home/$USERNAME/.ssh/id_rsa': "
send "$pass\r"
expect eof
EOD
关于bash - 在 bash 脚本中向 git 提供密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34155308/