Last Updated on 2021-10-23 by Clay
The laptop I used for work burned out, so I reinstalled an old laptop. Of course I need to configure its environment before my work laptop repair, to survive the work required during this period.
The most important thing is that I need to synchronize some of the projects on GitHub. In order to let GitHub know that my old laptop has access to the remote repository, it needs to set up an ssh key.
The steps of ssh key configuration
Step 1: Generate key
You can use the following command to generate the key:
ssh-keygen
Press Enter until the generation finished; the key file (id_rsa and id_rsa.pub) will put at ~/.ssh/ path.
Step 2: Upload key to GitHub (id_rsa.pub)
Go to GitHub website, open the top right corner icon menu, select Settings option.
Select SSH and GPG keys option on the left side.
Add the New SSH key.
You can set any title, and paste the id_rsa.pub content. Be careful that it must be exactly the same as the key, and one more space does not work.
Step 3: Configure GitHub personal account information
I always forget this step so record it by the way. Set your current device to git settings.
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
References
- https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent?utm_source=Blog
- https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key