-
Notifications
You must be signed in to change notification settings - Fork 889
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
Repository.Clone doesn't support SSH #255
Comments
Now that libgit2 has support for SSH, I was looking at what was needed to get this working. Changing the C# code looks straightforward, although I'm not sure the preferred way to change the API. The simplest would be to just throw a bunch more properties onto the Credentials object. I would prefer something like multiple Credentials objects, each with their own implementation of the aquire_credentials callback method, like...
Then we use this authenticate method in RemoteCallbacks. Either way, I could do this. The issue really is that in order for SSH to work, libgit2 will need to be built with libssh2, (which itself has even more dependencies). I was able to get some of these libraries building on Windows, but I'm sort of out of my league on this one; what is the right way to have this project build libgit2 with SSH support? Does the powershell script need updating to include all of the dependencies? Or is there a better way? |
👍 for multiple credential types, though that |
@dahlbyk 👍 @markhildreth I've recently discussed a bit about this topic in GitTools/GitVersion#38 (comment).
These are awesome news! Do you think you could try and produce a script to automate this process? Warning: I'm not sure libgit2/ssh has ever been tested on Windows. There may be dragons out there 😉 |
Regarding the API, I just helped out with the design for Rugged's implementation of this. Here are the use cases we came up with for Rugged; Libgit2Sharp might be different, but maybe not.
Case 1 wants a simple way to provide a single |
@dahlbyk: 👍 to the abstract method. @nulltoken: I think you're right with what you said in the other ticket regarding the Crypt API: nice idea, but does limit the platform support. Also, it isn't available yet. I'll see what I can do on a script for automating the libssh2 build including dependencies. We'll see how things go. @ben: I think I'm missing the point of the callback. What is lost by creating the Credentials object before calling |
Yeah, that's basically it. Here's what libgit2 does:
Say I'm writing a GUI git client, and the user wants to clone a private repo from GitHub. Libgit2 will try the connection and get a 401, which returns control to my code. I can check my credential cache, and try the creds I've got stored there, and if that doesn't work, I can fall back to asking the user for credentials, and telling them it failed until they get it right or hit cancel. Passing a Either way, this: Repository.Clone( /* … */, credentials: (url, types) => new Credentials("user", "pass")); Isn't much harder to write than this: Repository.Clone( /* … */, credentials: new Credentials("user", "pass")); …and gives the caller a lot more flexibility. |
Okay, I went WAY too far down the rabbit hole on this one. Here is my result of trying to get all these dependencies compiled (note: I'm trying to use Visual Studio for the compile, I didn't even look at MinGW)... To compile libgit2 with SSH, we need libssh2. libssh2 requires openssl or gcrypt.
The main problem that I ran into was that libgit2 would not link against the libssh2 library unless I changed libssh2's calling convention from __cdecl to __stdcall. However, if I did that then I couldn't link against OpenSSL. Attempting to compile OpenSSL with __stdcall lead to...
Like I said before, this is not an area of expertise for me, so I might be missing something that someone who works with C more than once a decade would understand. Another thing I noticed was that in addition to compiling SSH support, src/transport.c in libgit2 will need to be patched, as right now even if you have the GIT_SSH compiler flag enabled it will still not allow you to use SSH on Windows (see here). So, I see three main hurdles here:
Unless I can get pointed in the right direction, I'm probably going to stop work on this. The Windows Cryptography Patch for libssh2 makes all of this moot at the cost of not working on XP/Windows Server 2003 and lower, but it would be better than nothing and probably easier to build. |
The patch for the NG Crypto patch for libssh2 is in. http://git.libssh2.org/?p=libssh2.git;a=commit;h=4440e05d488e115bb4c398532fd24707f5dc1915;js=1 |
As discussed in #739, maybe could we also resolve this through a NuGet dependency chain. Make libssh2 a NuGet package, make libgit2 depend on it and eventually make LibGit2Sharp depend on libgit2. This would solve the Windows side. |
This may be confusing for Windows folk, but on the unix side, we have these things called package managers. They're a bit like NuGet but for the software on our machines :p On Linux/OSX and apt-get/yum/brew install libssh2(-dev) is all you need. The script might want to complain/advise if it's missing, but other than that, it doesn't need to bother with this. |
You *nix guys are mean! You stole us the whole NuGet idea years before we came up with the concept. You can't be trusted 👅
Is there a way to select a specific commit sha? |
No, but you don't need to; they don't break the API like we do. Whatever you have in the 1.x timeframe, we can deal with; or at least >= 1.4, since that's been their current release the whole time we've used libssh2, but that's been out for 18 months or so now. Or did I misunderstand the question? |
http://git.libssh2.org/?p=libssh2.git;a=summary;js=1 1.4.3 has been released 18 months ago. How can we target this unreleased branch while still knowing which "commit" we're working against (for troubleshooting purpose mainly)? |
On unix, we're already fine with ssh support and don't need to do anything. On Windows, we can target our own packages until there's something more official. |
Pffff. You really need to start using a decent OS 🚎 |
A work in progress in libgit2 (see libgit2/libgit2#2428) should help make LibGit2Sharp support Ssh more easily. |
👍 |
The WIP mentioned by @nulltoken is now implemented: libgit2/libgit2#2600 Should be a bit eeasier now to implement it.. |
Guys, is ssh still not supported in libgit2 and libgit2sharp, right? |
@dannyzhan See my answer to your very similar question in libgit2/libgit2sharp.nativebinaries#7 |
Which issue exactly is the main one now to follow progress of SSH implementation? #1072? Trying to figure out the current state to fetch repo's using an SSH key (used as deployment key in github) |
libgit2 and libgit2 do support SSH. The libgit2 we ship does not, as we do not want to ship 3rd-party crypto software in our packages. |
@carlosmn If libgit2 already requires libssh2 to use ssh, then you do not need to ship an additional 3rd-party crypto software in your package, since libssh2 now has native Windows support using WinCNG. |
I think libssh2 is the third-party crypto that he was referring to. |
Yes. While the cryptographic primitives are implemented by OpenSSL or And on UNIX we want to use the system libraries, but that would make the dload/GetProcAddress is an alternative to linking directly, but nobody has
|
I'm a little confused about the state of this issue. Is the ssh protocol supported for windows? |
@ckuhn203 Not out of the box, you have to build it and link it yourself. |
Got it. Thanks @ethomson. |
@ethomson is there some documentation how to do that? |
When performing a Repository.Clone against an SSH uri, it fails with the following message:
An error was raised by libgit2. Category = Net (Error).
This transport isn't implemented. Sorry
I'm guessing this just isn't implemented in libgit2 yet, though it looks to be on its way:
libgit2/libgit2#1103
The text was updated successfully, but these errors were encountered: