在bash脚本中向git提供密码 [英] Provide passphrase to git in bash script

查看:214
本文介绍了在bash脚本中向git提供密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在bash脚本中使用git fetch/pull提供密码短语. 我真的需要在bash脚本中执行此操作,而无需使用ssh-add或类似的内容. 有可能吗?

How do I provide passphrase with git fetch/pull in bash script. I really need to do it in a bash script, without using ssh-add or something like that. is it possible?

推荐答案

我尝试使用SSH_ASKPASS进行ssh-agent和解决方案,但没有任何效果,然后我找到了使用

I tryed ssh-agent and solution with SSH_ASKPASS but nothing worked, then I found a solution using http://expect.sourceforge.net/

示例(在shell中执行):

Example(executed in 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脚本中向git提供密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆