Why is flutter pub get not finding my ssh-key for github?
The problem was that Windows did't use the correct ssh programm and instead of openssh was using it's internal ssh program, which of course didn't know about my keys in openssh.
git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"
So after configuring git to use OpenSSH, flutter pub get
finds my keys, asks for a password and pulls the package correctly.
Thanks to https://github.com/desktop/desktop/issues/5641#issuecomment-421801704
dirkbo
Freelance Sofware Engineer, Python, Django and Unity developer.
Updated on December 24, 2022Comments
-
dirkbo over 1 year
My flutter App depends on a module privately hosted on github.
When I runpub get
from Powershell, i get:Git error. Command: `git clone --mirror ssh://[email protected]: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'... [email protected]: 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
When I copy the failed command and run directly in the same powershell:
git clone --mirror [email protected]:dirkbo/repo-name.git C:\src\flutter\.pub-cache\git\cache\repo-name-123ba
Everything works fine:
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.
In my
pubspec.yaml
I tried:repo: git: ssh://[email protected]/dirkbo/repo-name.git
(result see above)
and
repo: git: [email protected]:dirkbo/repo-name.git
which gives me:
Git error. Command: `git fetch` stdout: stderr: [email protected]: 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
It seems like the batch command running
pub get
can't find my ssh key.