Git how to clone with SSH key, username

前端 未结 4 1238
一整个雨季
一整个雨季 2021-02-07 05:20

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
4条回答
  •  失恋的感觉
    2021-02-07 06:15

    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"
    

    This way it will apply this config and use a key different than id_rsa before actually fetching any data from the git repository.

    subsequent fetch or push will use the specified key to authenticate for the cloned repository.

    Hope this is helpful to anyone.

提交回复
热议问题