前置#
Ensure that the terminal can use the git and ssh-keygen commands normally.
检查系统内是否已经有 ssh 密钥#
For Linux and MacOS terminals:
ls ~/.ssh
git 全局配置#
git config --global user.name YourUsername
Example: git config --global user.name zhiao
git config --global user.email YourEmail
Example: git config --global user.email [email protected]
生成秘钥#
ssh-keygen -t rsa -C 'TheEmailYouConfiguredInGitAbove'
Example: ssh-keygen -t rsa -C '[email protected]'
将公钥粘贴进 Github#
github->Profile Avatar at the top right corner->Settings->SSH and GPG keys->New SSH key
- Enter a Title
- Go to the ~/.ssh directory in the terminal, copy the content of the file ending with .pub, and paste it into the Key field
- Add SSH key