简体   繁体   English

git@github.com:使用纱线安装github js package时权限被拒绝(公钥)

[英]git@github.com: Permission denied (publickey) when using yarn to install github js package

Today when I execute the yarn command in the macOS(Intel Chip), show error like this:今天我在 macOS(英特尔芯片)中执行 yarn 命令时,显示如下错误:

$ yarn                                                                                                 ‹ruby-2.7.2›
yarn install v1.21.1
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍  Resolving packages...
warning webpack > watchpack > watchpack-chokidar2 > chokidar > fsevents > node-pre-gyp@0.12.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
[2/4] 🚚  Fetching packages...
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads ssh://git@github.com/jiangxiaoqiang/js-wheel.git
Directory: /Users/dolphin/source/reddwarf/frontend/Cruise-Radar
Output:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
(base)

and I config the js-wheel in package.json like this:我在 package.json 中配置js-wheel ,如下所示:

"js-wheel": "jiangxiaoqiang/js-wheel",

why still tell me permission denied even though the repo is public?即使回购是公开的,为什么还要告诉我权限被拒绝? I have tried using this command to generate the rsa key:我尝试使用此命令生成 rsa 密钥:

$ ssh-keygen -t rsa -b 4096 -C “balabala@gmail.com”                                              ‹ruby-2.7.2›
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/dolphin/.ssh/id_rsa):
/Users/dolphin/.ssh/id_rsa already exists.
Overwrite (y/n)?
(base)

what should I do to avoid this problem?我应该怎么做才能避免这个问题? When I using the https in the package.json, why the yarn still using the git way to fetch code?当我在package.json中使用https时,为什么纱线仍然使用ZBA9F11ECC33497D19953B的方式来取3497D19953B代码?6 This is my dependencies config in package.json :这是我在package.json中的依赖项配置:

"js-wheel": "https://github.com/jiangxiaoqiang/js-wheel.git",

BTW, I have already add the config in GitHub Actions, this is the full github action script:顺便说一句,我已经在 GitHub 操作中添加了配置,这是完整的 github 操作脚本:

name: cruise-web-pro

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16
      # https://stackoverflow.com/questions/71318659/gitgithub-com-permission-denied-publickey-when-using-yarn-to-install-github
      - name: Build React App
        run: |
          git config --global url.https://github.com/.insteadOf git@github.com: 
          npm install yarn -g
          yarn
          yarn build

      - name: Build image push to aliyun
        uses: docker/build-push-action@v1
        with:
          registry: ${{ secrets.ALI_DOCKER_HUB_REGISTRY }}
          username: ${{ secrets.ALIYUN_DOCKER_REPO_USER_NAME }}
          password: ${{ secrets.ALIYUN_DOCKER_REPO_USER_PASSWORD }}
          tags: ${{ github.sha }}
          repository: reddwarf-pro/cruise-web
          path: '.'
    
       # https://github.com/steebchen/kubectl
      - name: deploy to cluster
        uses: steebchen/kubectl@v2.0.0
        with: # defaults to latest kubectl binary version
          config: ${{ secrets.KUBE_CONFIG_DATA }}
          command: set image --record deployment/cruise-web cruise-web=registry.cn-hangzhou.aliyuncs.com/reddwarf-pro/cruise-web:${{ github.sha }} -n reddwarf-pro

      - name: verify deployment
        uses: steebchen/kubectl@v2.0.0
        with:
          config: ${{ secrets.KUBE_CONFIG_DATA }}
          version: v1.21.0 # specify kubectl binary version explicitly
          command: rollout status deployment/cruise-web -n reddwarf-pro

You need first to check if ssh -Tv git@github.com authenticates you, meaning if its output ends with a greeting message with your GitHub username. You need first to check if ssh -Tv git@github.com authenticates you, meaning if its output ends with a greeting message with your GitHub username.

As long as that won't work, a git ls-remote ssh://git@github.com/... would not work.只要这不起作用, git ls-remote ssh://git@github.com/...就不起作用。

The alternative is to force the use of HTTPS URLs:另一种方法是强制使用 HTTPS URL:

git config --global url.https://github.com/.insteadOf git@github.com:

That would work especially for public repositories, since no credentials would be needed.这尤其适用于公共存储库,因为不需要凭据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 git@github.com:权限被拒绝(公钥) - git@github.com: Permission denied (publickey) Git Submodule git@github.com:权限被拒绝(公钥)错误 - Git Submodule git@github.com: Permission denied (publickey) error git@github.com:权限被拒绝(公钥)。 但是 ssh git@github.com 有效 - git@github.com: Permission denied (publickey) . But ssh git@github.com works 获取ssh git@github.com:权限被拒绝(公钥) - Fetching ssh git@github.com: Permission denied (publickey) git@github.com:权限被拒绝(公钥)错误 - git@github.com: Permission denied (publickey) ERROR 为什么 git@github.com:Windows 中的权限被拒绝(公钥)? - Why git@github.com: Permission denied (publickey) in windows? 我收到此错误 git@github.com: Permission denied (publickey), 当我在新 Mac 上 git push 时 - I get this error git@github.com: Permission denied (publickey), when I git push on new mac 如何解决 npm install react-select failure with error: An unknown git error occurred, git@github.com:Permission denied (publickey) - How to solve npm install react-select failure with error : An unknown git error occurred, git@github.com :Permission denied (publickey) OpenSSH:git@github.com权限被拒绝 - OpenSSH: git@github.com permission denied Git 子模块:git@github.com:权限被拒绝(公钥)。 致命:无法从远程存储库中读取 - Git submodule: git@github.com: Permission denied (publickey). fatal: Could not read from remote repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM