git bash 命令出现Permission denied (publickey)问题

问题复现
$ ssh -T git@github.com
Permission denied (publickey).

在这里插入图片描述
本地刚创建ssh密钥进行连接时发现如上报错

排错过程
  1. 使用以下命令看有没有known_hosts文件
ls ~/.ssh/

在这里插入图片描述
2. 打开known_hosts文件看有没有我们ssh密钥如下
在这里插入图片描述
这里需要比对ip地址(公网地址),密钥key是不是和我们生成的xx.pub里面的内容是否一致

  1. 查看ssh连接debug日志
ssh -v git@github.com
OpenSSH_7.1p2, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [13.250.177.223] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/skindow/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/skindow/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/skindow/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/skindow/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/skindow/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/skindow/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/skindow/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/skindow/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version babeld-dae25663
debug1: no match: babeld-dae25663
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/skindow/.ssh/known_hosts:1
Warning: the RSA host key for 'github.com' differs from the key for the IP address                                                                                                              '13.250.177.223'
Offending key for IP in /c/Users/skindow/.ssh/known_hosts:3
Matching host key in /c/Users/skindow/.ssh/known_hosts:1
Are you sure you want to continue connecting (yes/no)?
Host key verification failed.

通过上面日志我们发现,一直在寻找文件 /c/Users/skindow/.ssh/id_rsa ,id_rsa该文件是你生成密钥的文件如下(缺少该密钥文件id_rsa导致的报错)
在这里插入图片描述
我们只需要将该文件放在 /c/Users/skindow/.ssh/目录下,并将名字改成id_rsa即可如下
在这里插入图片描述
修改玩之后我们再次尝试连接,并进行同步
在这里插入图片描述
文件成功拉取,错误完美解决!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值