打开终端
输入:
ssh-keygen -t rsa -C "xxx@xx.com"
回车,出现如下提示:
Last login: Tue Oct 31 10:20:24 on ttys004
bogon:~ YYKit$ ssh-keygen -t rsa -C "xxx@xxx.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xx/.ssh/id_rsa):
继续回车,中间会让输入两次密码,什么都不输入,继续回车,会出现如下内容:
Last login: Tue Oct 31 10:20:24 on ttys004
bogon:~ YYKit$ ssh-keygen -t rsa -C "xxxx@xxx.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xx/.ssh/id_rsa):
/Users/xx/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/xx/.ssh/id_rsa.
Your public key has been saved in /Users/xx/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:rp+6MLo27uTIONMqlO6/E9d9CvJzvVt5QI9I6Z2vy14 468466882@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| |
| . |
| o . |
| o + + |
| . . S o = . |
| o . o + . . + |
|o.. = o o + o E |
|*=+o o + + .o + |
|*XB=o ++= o+=. |
+----[SHA256]-----+
bogon:~ YYKit$
这时候,复制/Users/xxx/.ssh/id_rsa.pub.
,然后前往文件夹,
打开id_rsa.pub
,复制"xxx@xx.com"之前的部分。
这时候,来到Github
,在你的个人账户中,按照顺序依次点击“Settings --> SSH and GPG keys --> SSH keys --> New SSH Key
”,Title
可以写自己喜欢的标记,在Key
下面粘贴之前复制的内容,然后点击Add SSH Key
,之后可能会让你输入账户密码进行验证,这就就添加成功了。