因为重装了系统的缘故,一些以前的设置没法找了,参照官网,重新设置一下本地的 SSH key。
以下文章源自 github 官网,个人做了一些精简。
注意:
$
符号是需要输入的命令,>
是输入命令之后的一些显示结果
Generating a new SSH key and adding it to the ssh-agent
After you’ve checked for existing SSH keys, you can generate a new SSH key to use for authentication, then add it to the ssh-agent.
Generating a new SSH key
Open Git Bash.
1
$ cd ~/.ssh
Paste the text below, substituting in your GitHub email address.
1
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
When you’re prompted to “Enter a file in which to save the key,” press Enter. This accepts the default file location.
1
> Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]
At the prompt, type a secure passphrase, press Enter.
1
2> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]
Adding your SSH key to the ssh-agent
Ensure the ssh-agent is running:
1
2$ eval $(ssh-agent -s)
> Agent pid 59566Add your SSH private key to the ssh-agent.
1
$ ssh-add ~/.ssh/id_rsa
Checking for existing SSH keys
Before you generate an SSH key, you can check to see if you have any existing SSH keys.
Open Git Bash.
1
$ cd ~/.ssh
Enter ls to see if existing SSH keys are present:
1
2$ ls
> id_rsa id-rsa.pub //SSH keys are existing.
Adding a new SSH key to your GitHub account
To configure your GitHub account to use your new (or existing) SSH key, you’ll also need to add it to your GitHub account.
Copy the SSH key to your clipboard.
1
$ clip < ~/.ssh/id_rsa.pub
In the upper-right corner of any page, click your profile photo, then click Settings.
In the user settings sidebar, click SSH and GPG keys.
Click New SSH key or Add SSH key.
In the “Title” field, add a descriptive label for the new key. For example, if you’re using a personal Mac, you might call this key “Personal MacBook Air”.
Paste your key into the “Key” field.
Click Add SSH key.
If prompted, confirm your GitHub password.
参考连接: