如何生成ssh秘钥连接到github
由于本地Git仓库和Github仓库之间的传输是通过SSH加密的,所以连接时需要设置一下。
主要分为两一在本地创建SSH KEY,第二在github上完成SSH Key的加密。具体步骤如下:
本地创建SSH KEY
第一步:
找到git文件夹目录双击 启动命令框
如果没有git 可进行学习安装
检查本机是否有ssh key设置
$ cd ~/.ssh 或cd .ssh
如果没有则提示: No such file or directory
如果有则进入~/.ssh路径下(ls查看当前路径文件,rm * 删除所有文件)
第二步:
执行命令$ ssh-keygen -t rsa -C "xxxxxx@yy.com"
建议填写自己真实有效的邮箱地址.
密码可以为空 回车即可,
Your id 大专栏 使用ssh连接githubentification has been saved in /c/Users/xxxx_000/.ssh/id_rsa. #生成的密钥
Your public key has been saved in /c/Users/xxxx_000/.ssh/id_rsa.pub. #生成的公钥
The key fingerprint is:
e3:51:33:xx:xx:xx:xx:xxx:61:28:83:e2:81 xxxxxx@yy.com
* 本机已完成ssh key设置,其存放路径为:c:/Users/xxxx_000/.ssh/下 *。
添加ssh key到GItHub
登录GitHub系统;点击右上角账号头像的“▼”→Settings→SSH kyes→Add SSH key。
测试ssh keys是否设置成功
$ ssh -T git@github.com
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes #确认你是否继续联系,输入yes
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/xxxx_000/.ssh/id_rsa': #生成ssh kye是密码为空则无此项,若设置有密码则有此项且,输入生成ssh key时设置的密码即可。
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. #出现词句话,说明设置成功。
- 谢谢观看 *