Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh running under Braid fails to prompt for passphrase on Windows #91

Open
Devmeon opened this issue Oct 1, 2020 · 5 comments
Open

Comments

@Devmeon
Copy link

Devmeon commented Oct 1, 2020

I am having an issue while adding a mirror by using ssh.
I had this error another time and bypassed the error by using https link to the repository.

But this time, i only have ssh access to the repository of the project.
I successfully cloned the project by using the SSH link(git clone ssh,) but it does not work passing by braid.

Command line :
braid add --verbose ssh://git@IP/rac/project.git Externe/M2M

Output :
Braid: Executing git --version` in D:/Devmeon/AMC/erdf-c1c4

Braid: Executing git rev-parse --is-inside-work-tree in D:/Devmeon/AMC/erdf-c1c4
Braid: Executing git rev-parse --show-prefix in D:/Devmeon/AMC/erdf-c1c4
Braid: Executing git status in D:/Devmeon/AMC/erdf-c1c4
Braid: Executing git rev-parse HEAD in D:/Devmeon/AMC/erdf-c1c4
Braid: Executing git add .braids.json in D:/Devmeon/AMC/erdf-c1c4
Braid: Adding mirror of 'ssh://git@IP/rac/project.git'.
Braid: Executing git --version in D:/Devmeon/AMC/erdf-c1c4
Braid: Executing git rev-parse --is-inside-work-tree in D:/Devmeon/AMC/erdf-c1c4
Braid: Executing git rev-parse --show-prefix in D:/Devmeon/AMC/erdf-c1c4
Braid: Executing git config remote.master/braid/Externe/M2M.url in D:/Devmeon/AMC/erdf-c1c4
Braid: Setup: Mirror 'Externe/M2M' already has a remote. Replacing it (force)
Braid: Executing git remote rm master/braid/Externe/M2M in D:/Devmeon/AMC/erdf-c1c4
Braid: Setup: Creating remote for 'Externe/M2M'.
Braid: Executing git remote add master/braid/Externe/M2M C:/Users/Tristan/.braid/cache/ssh___git_IP_rac_project.git in D:/Devmeon/AMC/erdf-c1c4
Braid: Executing git config remote.master/braid/Externe/M2M.url in D:/Devmeon/AMC/erdf-c1c4
Braid: Executing git clone --mirror ssh://git@IP/rac/project.git C:/Users/Tristan/.braid/cache/ssh___git_IP_rac_project.git in D:/Devmeon/AMC/erdf-c1c4
Braid: Resetting to 'c4d9820'.
Braid: Executing git reset --hard c4d98205dd713a7de7c1161664a4f69b056d2216 in D:/Devmeon/AMC/erdf-c1c4
Braid: Shell error: Cloning into bare repository 'C:/Users/Tristan/.braid/cache/ssh___git_IP_rac_project.git'...`

Edit, full error message :
`git@IP: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.`

The indicated command line is working when i execute it outside braid :
`D:\Devmeon\AMC\erdf-c1c4>git clone --mirror ssh://git@IP/rac/project.git

Cloning into bare repository 'project.git'...
Enter passphrase for key '/c/Users/Tristan/.ssh/id_rsa':
remote: Enumerating objects: 63, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 63 (delta 17), reused 0 (delta 0) eceiving objects: 63% (40/63)
Receiving objects: 100% (63/63), 24.47 KiB | 501.00 KiB/s, done.
Resolving deltas: 100% (17/17), done.`

braid version : braid 1.1.3
git version : git version 2.27.0.windows.1

@mattmccutchen
Copy link
Collaborator

As I said at #90 (comment), in order to troubleshoot this, we'll need to see the full error from git clone. Either modify your copy of Braid locally as I described there (if you can), otherwise wait for us to release a version of Braid with the error reporting fixed. You could also try manually running the indicated command line in the indicated working directory to see if you can reproduce the problem. Until one of those happens, this issue will be on hold.

@Devmeon
Copy link
Author

Devmeon commented Oct 2, 2020

I have edited the issue, i modified my local braid copy.
And tried to reproduce the problem but it only occurs when using braid.

@mattmccutchen
Copy link
Collaborator

Thanks for providing the full error. It looks like the problem might be that ssh is unable to prompt for the passphrase when running under Braid because Braid redirects both stdout and stderr and perhaps also stdin. IIUC, ssh uses /dev/tty to prompt for the passphrase on Linux, precisely to work in case the usual file descriptors are redirected. Maybe this isn't working in Git for Windows's msys2 environment for some reason. I'll need to test this to confirm it. If so, we can see if there's a way Braid can avoid the problem, or we can document it as a limitation.

Possible workarounds:

  • Configure ssh so it doesn't prompt for a passphrase when running under Braid, e.g., load the key into an ssh agent (and enter the passphrase) beforehand, or use a different credential helper as suggested here.
  • Make your own local clone of the repository for Braid to use and update it before each time you run Braid. When the problem is fixed, you'll just need to edit .braids.json to point to the original repository.

@Devmeon
Copy link
Author

Devmeon commented Oct 2, 2020

Well, i have removed the passphrase from my ssh key using "ssh-keygen -p".
And Braid add/update is working as expected, so it is really a problem with passphrase.

@mattmccutchen mattmccutchen changed the title braid add error with ssh ssh running under Braid fails to prompt for passphrase on Windows Oct 2, 2020
@mattmccutchen
Copy link
Collaborator

Thanks for confirming what the problem was; I've updated the issue title accordingly.

More broadly, thanks for supporting Braid and helping us identify three(!) bugs. I think many more people could benefit from Braid if they knew about it, and I'd like to see how people are using Braid now to see if we can do anything better, but GitHub stars and mentions on the web (including .braids.json files in people's repos) are an imperfect measure, so bug reports help. Unfortunately, I am pretty busy at the moment and don't know when I'll get around to fixing the bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants