git - 为什么flutter pub找不到我的github ssh-key?

标签 git flutter github ssh

我的 flutter 应用程序依赖于一个私有(private)托管在 github 上的模块。
当我运行 pub get从 Powershell,我得到:

Git error. Command: `git clone --mirror ssh://git@github.com:dirkbo/repo-name.git C:\src\flutter\.pub-cache\git\cache\repo-name-123ba`
stdout:
stderr: Cloning into bare repository 'C:\src\flutter\.pub-cache\git\cache\repo-name-123ba'...
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.
exit code: 128
当我复制失败的命令并直接在同一个 powershell 中运行时:
git clone --mirror git@github.com:dirkbo/repo-name.git C:\src\flutter\.pub-cache\git\cache\repo-name-123ba
一切正常:
Cloning into bare repository 'C:\src\flutter\.pub-cache\git\cache\repo-name-123ba'...
Enter passphrase for key '/c/Users/dirkb/.ssh/id_rsa':
remote: Enumerating objects: 229, done.
remote: Counting objects: 100% (229/229), done.
remote: Compressing objects: 100% (132/132), done.
remote: Total 229 (delta 13), reused 229 (delta 13), pack-reused 0
Receiving objects: 100% (229/229), 19.32 MiB | 1.45 MiB/s, done.
Resolving deltas: 100% (13/13), done.
在我的 pubspec.yaml我试过:
repo:
    git: ssh://git@github.com/dirkbo/repo-name.git
(结果见上)
repo:
    git: git@github.com:dirkbo/repo-name.git
这给了我:
Git error. Command: `git fetch`
stdout:
stderr: 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.
exit code: 128
好像批处理命令正在运行 pub get找不到我的 ssh key 。

最佳答案

问题是 Windows 没有使用正确的 ssh 程序,而不是 openssh 使用的是它的内部 ssh 程序,它当然不知道我在 openssh 中的 key 。git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"所以配置git使用OpenSSH后,flutter pub get找到我的 key ,要求输入密码并正确 pull 出包裹。
感谢 https://github.com/desktop/desktop/issues/5641#issuecomment-421801704

关于git - 为什么flutter pub找不到我的github ssh-key?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63826538/

相关文章:

flutter - 在字符串插值中获取statusCode错误

android - flutter - 在运行 Android 4.4 (Kitkat) 的小米设备上崩溃 - Firebase 错误

Git merge 冲突,但没有明显的区别

maven - 如何将包发布到 GitHub 包存储库?

linux - 当我使用协作 github 存储库时,crontab 无法识别 github 用户名

git - 创建远程主机的分支

Git 无法在内部处理 LOG

flutter - PageView.animateToPage 不适用于 elasticInOut 动画

c++ - 从 https ://github. com/boostorg/boost.git 在 Windows 上构建 Boost

windows - 由于文件名中的字符无效,在 Windows 上克隆存储库时出错