1.创建SSH Key
ssh-keygen -t rsa -C "你的邮箱账号"
回车键后会有下面显示:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/now/.ssh/id_rsa): '这里输入文件名字 比如id_rsa'
然后会提示让输入密码:这个密码是 push时候的密码 不是github的密码
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
会有下面提示
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
SHA256:6z7Ya7lLkRKld266nSb6oKcAkCm0Sv/zSmud2R/U2uM you-mail@mail.com
The key's randomart image is:
+---[RSA 2048]----+
| . . |
|.o. o |
|=o o . . |
|= . o + . |
|o . . S o. . |
| . . . =. o |
| . +ooB. o o |
| ..o*B*+..o . |
| +=o*OB+. E |
+----[SHA256]-----+
这就创建完成了,然后找到id_rsa.pub文件 可以拖到浏览器查看文件内容,复制。
2.把SSH Key添加到Github仓库中
打开Github ->设置 –> SHH和GPG秘钥 -> New SSH key
把获取到秘钥粘贴进去就ok了
3、验证是否可用
在终端输入:
ssh -T git@github.com
出现下面就可以用了
Hi 用户名! You've successfully authenticated, but GitHub does not provide shell access.
网友评论