当前位置:   article > 正文

npm报错fatal: Could not read from remote repository_host key verification failed. npm err! fatal: coul

host key verification failed. npm err! fatal: could not read from remote rep


一、问题描述

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

二、解决方法

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

1.生成新的SSH key

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

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.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/698679
推荐阅读
相关标签
  

闽ICP备14008679号