简体   繁体   English

Git克隆自动化错误权限被拒绝(公钥)

[英]Git clone automation error Permission denied (publickey)

I want to automate git clone by using shell script. 我想通过使用Shell脚本来自动化git clone。 I use git clone -b branch "$repository" but it gives error : 我使用git clone -b branch "$repository"但它给出了错误:

Permission denied (publickey). 权限被拒绝(公钥)。 fatal: Could not read from remote repository. 致命:无法从远程存储库读取。

but i have already added the ssh key to my account and i can clone manually using the same command. 但是我已经将ssh密钥添加到我的帐户,并且可以使用同一命令手动克隆。 What can i do to fix it? 我该如何解决?

What can i do to fix it? 我该如何解决?

Double-check what $repository value actually is during the script execution. 仔细检查脚本执行过程中$ repository的实际值。
That means: echo the line 这意味着:回显线

echo git clone -b branch "$repository"

Then, if the command displayed by the script is the right one (you can copy-paste it manually, and it is working), make sure the script is used with the same account as yours. 然后,如果脚本显示的命令是正确的命令(您可以手动将其复制粘贴,并且可以正常工作),请确保该脚本使用与您相同的帐户。

I have found the solution for it. 我已经找到了解决方案。 All I miss was to start the ssh-agent and add the id_rsa by 我想念的只是启动ssh-agent并添加id_rsa

eval "$(ssh-agent -s)" 评估“ $(ssh-agent -s)”

ssh-add ~/.ssh/id_rsa ssh-add〜/ .ssh / id_rsa

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM