When synchronizing a code base on GitHub from GitHub using the git clone command, if you use SSH links (such as my own Beagleos project: [email protected]:D amondeng/beagleos.git), and your SSH Key is not added to the GitHub account settings, the system will report the following error:
Permission denied (PublicKey).
Fatal:the remote end hung up unexpectedly
You will need to create an SSH key locally and then add the generated SSH key file content to your GitHub account.
The way to create SSH keys is simple, and you can do this by following these commands:
Ssh-keygen
Then the system prompts for information such as file save location, three consecutive hit enter, the generated SSH key file saved in the ~/.ssh/id_rsa.pub
Then open the file with the text Editing tool, I use VIM, so the command is:
Vim ~/.ssh/id_rsa.pub
Then copy the content in the. ssh/id_rsa.pub file and paste it into the Add SSH key interface in GitHub account management.
To open the Add SSH key interface in GitHub account management, follow these steps:
1. Login to GitHub
2. Click the Accounting settings icon in the top right
3. Select SSH Key
4. Click Add SSH Key
In the interface that appears, fill in the name of the SSH key, fill in a name you like, and then paste the contents of the ~/.ssh/id_rsa.pub file into the key column, click on the "Add Key" button.
Add a process github will prompt you to enter your GitHub password once
After adding it, execute git clone again to successfully clone the code base on GitHub.
Add SSH keys to your github account