[英]Passing password during git clone from shell script
I have written a shell script to clone the project from multiple location which is sent as a file. 我编写了一个Shell脚本来从多个位置克隆项目,该文件以文件形式发送。 I read the file and pass the each location in a loop and perform my operation.
我读取文件并循环传递每个位置并执行我的操作。
LocationFile.txt LocationFile.txt
Project1=https://enduser1@stash.my.org/my/path/testProject1.git
Project2=https://enduser2@stash.my.org/my/path/testProject2.git
Project3=https://enduser3@stash.my.org/my/path/testProject3.git
Project4=https://enduser4@stash.my.org/my/path/testProject3.git
Password.txt 密码.txt
Project1=password1
Project2=password2
Project3=password3
Project4=password4
I have a password file encrypted and stored in server, which I can read as part of script and passing into my script When I run my script during clone step its prompting for a password, I tried to pass the password like below which is not working 我有一个加密的密码文件,并存储在服务器中,可以将其作为脚本的一部分读取并传递到脚本中。在克隆步骤中运行脚本时,系统会提示输入密码,但我尝试通过以下密码进行操作,但该密码无法正常工作
##############
gitpassword=$password1 #retrieved from Password.txt
for xxx
do
...
...
git clone "${ProjectArrayList[1]}"
read $gitpassword
...
..
done
##############
I know I can do password less if I use ssh, which I don't want to do. 我知道如果我不想使用ssh,则可以减少密码。 Is there a way to achieve this with my exsiting approach
有没有办法通过我现有的方法来实现这一目标
Git has a "credential helper" that can do the job [it is designed to work over https]. Git有一个“凭证助手”可以完成这项工作[它旨在通过https工作]。
See: https://git-scm.com/docs/git-credential-store and https://help.github.com/articles/caching-your-github-password-in-git/ 参见: https : //git-scm.com/docs/git-credential-store和https://help.github.com/articles/caching-your-github-password-in-git/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.