git初始化配置,解决ssh-key本地秘钥绑定,从git上clone拉取项目

报错:

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository

场景:

使用SSH地址下载GitHub项目报错,原因是没有配置SSH keys
使用的命令:

git clone git@github.com:zhangbeizhen/demo-config.git

环境:

本例window10下载使用Git Bash客户端

1. 命令 

ssh-keygen -t rsa -C  邮箱地址

ssh-keygen -t rsa -C  youremail@163.com

本命令提示输入信息,回车即可。

2. 命令:

ssh -v git@github.com

3. 命令:

ssh-agent -s

4. 命令:

eval `ssh-agent -s`

5. 命令:

ssh-add ~/.ssh/id_rsa

6. 在本例生成的id_rsa.pub在C:\Users\lenovo\.ssh

7. 在github账号下设置:

    1>.进入github账号,
    2>.在settings页面,找到SSH and GPG keys
    3>.点击SSH keys 新建SSH keys
    4>.填写title(自定义名称),
    5>.将id_rsa.pub里的内容复制到Key中
    6>.点击Add SSH Key,完成

如图:

注意:

在C:\Users\lenovo\.ssh下有id_rsa和id_rsa.pub。

需完整复制id_rsa.pub内容,否则可能报错:

Key is invalid. It must begin with 'ssh-ed25519', 'ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256', 'ecds.....

8. 验证命令

ssh -T git@github.com

9. 下载

git clone git@github.com:zhangbeizhen/demo-config.git

本地测试实现:

git config --global user.name "姓名"
git config --global user.email "邮箱地址"
git config --global --replace-all user.name xiaoming
git config --global --replace-all user.email xxx@qq.com
~/.ssh 或者用~/.ssh ls
ssh-keygen -t rsa -C  XXX@qq.com
ssh -v git@github.com
ssh-agent -s
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa
ssh -T git@github.com
git clone git@github.com:dvajs/dva.git
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wespten

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值