Skip to content

How to add SSH key to Git Repo

  1. Set up your default identity. In terminal, write the command:

    ssh-keygen
    

  2. List the contents of ~/.ssh to view the key files.

    ls ~/.ssh
    

  3. Add the key to the ssh-agent. To start the agent, run the following:

    eval `ssh-agent`
    

  4. Add the public key to your online git settings. Open the account settings page, then find and go to the SSH Keys settings. You will be prompted to add a key to your account.

  5. Retreive the public key that you generated

    On Linux, you can cat the contents:

    cat ~/.ssh/id_rsa.pub
    

    On macOS, the following command copies the output to the clipboard:

    pbcopy < ~/.ssh/id_rsa.pub
    

  6. Select and copy the key output in the clipboard. Paste in the browser and click save.