【问题标题】:Host key verification failed when installing NPM module from private Bitbucket从私有 Bitbucket 安装 NPM 模块时主机密钥验证失败
【发布时间】:2020-08-27 13:55:52
【问题描述】:

我正在尝试从私有 Bitbucket 存储库安装 NPM 模块。

我可以在我的系统上本地成功运行npm install,但在服务器上却失败了。

错误是:

npm ERR! Error while executing:
npm ERR! /bin/git ls-remote -h -t ssh://git@bitbucket.org/myorg/my-repo.git
npm ERR! 
npm ERR! 
npm ERR! (ssh-askpass:10260): Gtk-WARNING **: cannot open display: :0.0
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

奇怪的是,手动克隆服务器上的 repo 可以正常工作: git clone git@bitbucket.org:myorg/my-repo

所以 SSH 密钥配置正确。

【问题讨论】:

    标签: git npm


    【解决方案1】:

    这应该表明 npm 命令未使用与用于在服务器上手动克隆 repo 的帐户相同的帐户执行。

    在那个 npm 帐户中,the ~/.known_hosts would need to be updated first

    【讨论】:

      【解决方案2】:

      我认为您正在从 Docker 容器访问它,因为您没有从 docker 容器添加 ssh 密钥,因此存在问题。所以有两种解决方案

      1. 不建议公开您的 Git 存储库

      2. npm 在 jenkins 上安装所有节点模块,然后复制所有节点模块 到码头集装箱。 (基本上不是在 Docker 容器上安装 npm 从 package.json,在 Jenkins 上执行,然后将这些模块复制到容器 直接

      docker 文件的变化将是

      INITIALLY :
      FROM node:12.10-alpine
      WORKDIR /app
      RUN apk update \
        && apk add git
      COPY node_modules /app
      COPY . /app
      ADD set_envs.sh .
      RUN ["chmod", "+x", "set_envs.sh"]
      EXPOSE 80
      ENTRYPOINT ["/app/set_envs.sh"]
      
      
      AFTER CHANGES :
      FROM node:12.10-alpine
      WORKDIR /app
      COPY node_modules /app
      COPY . /app
      ADD set_envs.sh .
      RUN ["chmod", "+x", "set_envs.sh"]
      EXPOSE 80
      ENTRYPOINT ["/app/set_envs.sh"]
      

      在 Jenkins 的 shell 脚本中 [in configure] 添加

      npm install
      

      就是这样,它应该可以工作

      【讨论】:

        猜你喜欢
        • 2018-10-04
        • 1970-01-01
        • 2020-12-27
        • 2017-03-19
        • 1970-01-01
        • 1970-01-01
        • 2021-12-25
        • 2013-02-16
        • 1970-01-01
        相关资源
        最近更新 更多