通过ssh连接github,可以有效的提升安全性

1.设置位置

2.生成ssh密钥(windows)

打开git bash,输入以下命名,把your_email@example.com换成自己的github账号

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

如果这里直接按回车,就会生成在默认的地方,如果已经生成过了,就会覆盖 如果要保存到d:/.ssh/github_rsa,在此输入(注意:文件夹必须存在)

/d/.ssh/github_rsa

提示增加证书的密钥,可以回车不加,是对证书的再次加密,建议使用

3.添加到ssh-agent

以下操作在git bash里面运行 检查ssh-agent是否运行,显示pid说明正常

eval "$(ssh-agent -s)"

添加ssh证书(路径是上面写的),并输入证书密码(如果有)

ssh-add /d/.ssh/github_rsa

4.将公钥(.pub)复制并保存

会提示输入github密码并确认

5.测试能否连接

注意,这里不要替换为自己的邮箱

ssh -T git@github.com

注意:网络不好可能导致无法连接,建议先解决网络问题 国内是可以直接访问github的,清理dns通常就能解决

6.设定git信息

git config --global user.name "username"

git config --global user.email "email"

7.项目配置

目录用/分开,比如c://aaa/aaa目录

cd /c/aaa/aaa

git 初始化

git init

添加(从github的code中可以查看地址)

git remote add origin git@github.com:yourName/repositoryname.git

git remote add origin https://github.com/yourName/repositoryname.git

然后可以克隆项目修改了

参考阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: