Git如何使用SSH密钥,用户名克隆 [英] Git how to clone with SSH key, username
问题描述
我有以下内容,我需要在Windows终端命令提示符或linux中克隆存储库.
I have the following and i need to clone the repository in either windows terminal command prompt or linux.
- URL: git@xxxxx.com:xxx/xxx/git
- 用户名: xxx@xxx.in
- SSH密钥:ssh-rsa AAAAB3NzaC1yxxxxxxxxxxxx .... xxx@xxx.in
- URL: git@xxxxx.com:xxx/xxx/git
- username: xxx@xxx.in
- SSH key: ssh-rsa AAAAB3NzaC1yxxxxxxxxxxxx....xxx@xxx.in
我尝试过:
git clone git@xxxxx.com:xxx/xxx/git
我知道
Permission denied(public key)
Couldn't read from remote repository
还尝试将URL更改为:
Also tried to change the URL as:
git clone https://xxxxx.com:xxx/xxx/git
推荐答案
总是迟来回答任何问题,您可能有多个ssh键,如果未指定,git会尝试使用id_rsa
,但是如果您需要一个可以使用的其他
Always coming late to answer anything, it may be possible that you have more than one ssh keys and if not specified git will try to use id_rsa
but if you need a different one you could use
git clone git@provider.com:userName/projectName.git --config core.sshCommand="ssh -i ~/location/to/private_ssh_key"
通过这种方式,它将应用此配置并使用与id_rsa
不同的键,然后才实际从git存储库中获取任何数据.
This way it will apply this config and use a key different than id_rsa
before actually fetching any data from the git repository.
随后的fetch
或push
将使用指定的密钥对克隆的存储库进行身份验证.
subsequent fetch
or push
will use the specified key to authenticate for the cloned repository.
希望这对任何人都有帮助.
Hope this is helpful to anyone.
这篇关于Git如何使用SSH密钥,用户名克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!