Step 1: 检查本地是否已经存在key文件
1 | cd ~/.ssh |
如果文件列表里面有 id_rsa.pub
或者 id_das.pub
,你可以跳过Step2 直接到Step3.
Step 2: 生成一个新的SSH Key1
2
3
4
5
6
7
8
9
10$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
# Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
Then add your new key to the ssh-agent1
$ ssh-add ~/.ssh/id_rsa
Step 3 添加SSH key 到github
- In the user bar in the top-right corner of any page, click Account settings.
- Click SSH Keys in the left sidebar.
- Click 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 key.
- Confirm the action by entering your GitHub password.
Step 4: 测试SSH
1 | $ ssh -T git@github.com |
原文 GitHub Hepl SSH.