Key exchange:

If you want to copy a repository with ssh and not https, you first have to exchange ssh keys. If you have already made an SSH key, but you have forgotten your passphrase to your current private key, you can just make a new one following this guide. You will be asked if you want to overwrite your old key.

I have made two different guides, one for Windows and one for MacOS/Linux:

For Windows:

  1. Open Command Prompt as administrator

    Press Windows key.

    Open command prompt by typing "cmd" and right click on "Command Prompt" and choose "run as administrator".

  2. Navigate to your home location, or the place you want to store your SSH key.

    You can use one of two commands:

    This command...

    cd %HOMEPATH%

    ... or this command...

    cd C:\Users\yourUser
  3. Create an SSH key

    To create an SSH key, write:

    ssh-keygen -t ed25519

    You will now get this question:

    Enter file in which to save the key (C:\Users\yourUser/.ssh/id_ed25519):

    Press enter to save the key in the default directory: C:\Users\yourUser/.ssh

    (If you have an old key you will get a message telling you it already exists and asks you if you want to overwrite it. Write y for yes.)

    Enter passphrase and choose something you can remember because it can not be restored, or just press enter if you don't want to use a passphrase. This passphrase is to protect your private SSH key. If you happened to forget your passphrase, you have to make a new key and add it to GitHub.

    Press enter until you see the key's randomart image.

  4. Copy your public key (not your private key)

    Navigate into the .ssh folder.

    cd .ssh

    Copy your public key:

    type id_ed25519.pub | clip

    If you are using git bash you can copy using cat:

    cat id_ed25519.pub | clip
  5. Add your public key to GitHub

    Then go to GitHub.

    Click on your profile image in the upper right corner and select "Settings".

    In the left margin choose "SSH and GPG keys". Click on "New SSH key".

    • Title: Choose a title, for instance "My PC"
    • Key type: Authentication key
    • Key: Paste the key you copied in the key field and press the button "Add SSH key"

For MacOS/Linux:

  1. Open terminal by clicking command + space, write "terminal" and press enter, and write:

    ssh-keygen -t ed25519
  2. Press enter to save the key in the default directory.

  3. Create a passphrase (if you want)

    Enter passphrase and choose something you can remember because it can not be restored, or just press enter if you don't want to use a passphrase.

    This passphrase is to protect your private SSH key. If you happened to forget your passphrase, you have to make a new key and add it to GitHub.

  4. Navigate to your .ssh folder

    Press enter a couple of times, until you see the key's randomart image. Then navigate into the .ssh folder:

    cd .ssh
  5. Copy your public key (not your private key):

    • On MacOS:

      pbcopy < ~/.ssh/id_ed25519.pub
    • On Linux:

      cat ~/.ssh/id_ed25519.pub | xclip -selection clipboard
  6. Add your key to GitHub

    Open GitHub, click on your profile image and select "Settings".

    Choose "SSH and GPG keys". Click on "New SSH key".

    • Title: Choose a title, for instance "My MacOS"
    • Key type: Authentication key
    • Key: Paste the key you copied in the key field and press the button "Add SSH key"