npm报错fatal: Could not read from remote repository

原文

一、问题描述

npm install 执行报错 fatal: Could not read from remote repository:

npm ERR! Error while executing:
npm ERR! d:\Program Files\Git\cmd\git.EXE ls-remote -h -t ssh://git@github.com/sohee-lee7/Squire.git
npm ERR!
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Program Files\nodejs\node_cache\_logs\2022-05-11T02_16_46_757Z-debug.log
12345678910111213

二、解决方法

原因是 GitHub 的客户端与服务端未生成 ssh key 或 ssh key 不匹配,需要重新生成。

1.生成新的SSH key

ssh-keygen -t rsa -C "youremail@example.com"

2.将 SSH key 添加到 GitHub 账户

选择 “Settings” –> “SSH and GPG keys” –> “New SSH key” ,将 id_rsa.pub 文件的密钥复制后填写进去:
在这里插入图片描述
在这里插入图片描述

3.验证 SSH key

使用 ssh -T git@github.com 对 SSH key 进行验证:

ssh -T git@github.com
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNICxxxxxIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
Hi xxxxx! You've successfully authenticated, but GitHub does not provide shell access.
123456
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值