gpt4 book ai didi

batch-file - 使用批处理文件运行 git clone 命令时如何提供密码

转载 作者:行者123 更新时间:2023-12-03 16:39:40 32 4
gpt4 key购买 nike

我正在制作一个自动克隆 git 存储库的批处理文件。
我将以下行添加到批处理文件中

git clone ssh://user@address/path

但它的执行击中了我:
[exec] Permission denied, please try again.
[exec] Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[exec] fatal: Could not read from remote repository.

因为它需要输入密码。
我尝试将命令更改为
git clone ssh://user:password@address/path

但它仍然要求我输入密码

有什么建议吗?

最佳答案

处理这个问题的最好方法是建立一个公钥,这样你就根本不需要密码。它也恰好更安全。例如创建一个新的 ssh key 对:

$ ssh-keygen -t rsa -f ~/.ssh/git_key -C "steve@example.com"
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/sowens/.ssh/git_key.
Your public key has been saved in /Users/sowens/.ssh/git_key.pub.
The key fingerprint is:
SHA256:BxqMCuLKKa47IEzmAk7yRpv7MHuIwn9YWp5zlMs0O9A steve@example.com
The key's randomart image is:
+---[RSA 2048]----+
| |
| o |
|o . o . |
|==.. o . |
|X+.o o S . |
|*+* + E . |
|B=oo* * + |
|*.o*.= * |
|=+o+o o . |
+----[SHA256]-----+

然后将新的 git_key.pub 文件添加到您的 github 帐户:

https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

该文件将是一个文本文件,如下所示:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDjk8Ae7kGBhBM/hAhxe4BpjU1HIymRel6TWGJ3E17lki9qJroNjXpqxtsd27C2QSgdEvYEbX6Qv1jeTejpDqTnPdWvjnOWnk5zAo7IhKdKqzCMkBblmHR4LoJs/CeTuNG2vyTx7hb93nBPjni2EV05jW/vkoMoZbMV/4lO1A4oX5L52h5/hGDahfOLxjoU3wfkEssQkDo83GHzk5A5O6kSb6Lv9TFdaWCMqI0ZXOj3CuH3CSCIpoqS1Kibceu3kLHLN8KQZEXQmMrBEkJ69RfugfNtTddOO3gjhVmCAAUzZsRuxGQMDgmT0tnpQaJ0DdSxFwpEFSceR0/06Zykq+dl steve@example.com

关于batch-file - 使用批处理文件运行 git clone 命令时如何提供密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39732840/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com