When using the git clone command to sync a code base on GitHub from GitHub, if you use an SSH link and your SSH key is not added to your 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 method of creating SSH key is very simple, the following command can be executed: Ssh-keygen, such as:
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