Mac OS | SSH-fatal: Could not read from remote repository.

Problem Description

When using SSH to connect to Github: git clone [email protected]:xxxxxxxxThe following error occurred:

Insert picture description here

Check existing SSH keys

Open the terminal and enter ls -al ~/.ssh:
Insert picture description here
There are three types of SSH public key file names by default:

  • id_rsa.pub
  • id_ecdsa.pub
  • id_ed25519.pub

Here I already have an SSH key (id_rsa.pub), if not, I need to generate a new SSH key .

Configure Github

Copy the public key

Terminal input: pbcopy < ~/.ssh/id_rsa.pub(XX.pub corresponds to your public key type). If pbcopy does not work, you can find the hidden .ssh folder in the corresponding directory, open the file with a text editor, and copy it to the clipboard.

Add public key

Click on the avatar in Github - Settings - SSH and GPG keys - New SSH key

Insert picture description here

Insert picture description here
Paste the content you just copied into the Key, and pick up the title:

Insert picture description here
After that, a confirmation password will pop up:
Insert picture description here

Test SSH connection

Type in the terminal ssh -T [email protected]:
Insert picture description here

Use SSH to connect to Github

Now you can successfully use git clonethe
Insert picture description here

Reference documents

https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/connecting-to-github-with-ssh

Guess you like

Origin blog.csdn.net/qq_43580646/article/details/112064186