Git how to clone with SSH key, username

前端 未结 4 1324
一整个雨季
一整个雨季 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:05

    I suggest that you follow those steps:

    Step 1: Check for existing SSH keys

    $> ls -al ~/.ssh

    Do you see any files named id_rsa and id_rsa.pub?

    If yes go to Step 3

    If no, you need to generate them

    Step 2: Generate a new SSH key

    $> ssh-keygen -t rsa -b 4096 -C "yourEmail"

    Add your SSH key to the ssh-agent

    $> eval "$(ssh-agent -s)"

    $> ssh-add ~/.ssh/id_rsa

    Step 3.1: Add the SSH key to your GIT account.

    Get your public key

    $> cat ~/.ssh/id_rsa.pub

    Go to your GIT project -> Settings -> SSH keys

    Then past the content of your public key in SSH keys

    Step 3.2: Force SSH Client To Use Given Private Key

    This is an alternative solution when you can't set keys on your Git account

    $> sudo nano ~/.ssh/config

    Then change this line

    IdentityFile

    Step 4: Clone the project

    $> git clone git@xxxxx.com:xxx/xxx/git

提交回复
热议问题