When I use libgit2sharp in project to clone repository with ssh-transport protocol, like
[email protected]:libgit2/libgit2sharp.git
It throw an exception, says "This transport isn't implemented. Sorry"
How can I clone repository with ssh-transport-protocol by using libgit2sharp ?
Unfortunately, Ssh protocol is not supported yet. At this time only git://
(read-only) and http[s]://
protocols are.
However, it will eventually be, by leveraging the libssh2 library.
Subscribing to issue #255 notifications will keep you updated about the progress made regarding this feature.
There's a work in progress in libgit2 (see PR #2428) that should help us make LibGit2Sharp able to cope with the ssh protocol sooner rather than later.
PR #852 is working on making ssh available to LibGit2Sharp
Unfortunately, LibGit2Sharp does not include necessary crypto libraries out of box (https://github.com/libgit2/libgit2sharp/issues/255#issuecomment-212580185).
Use LibGit2Sharp-SSH NuGet package (fork).
private void Run()
{
var url = "ssh://[email protected]/some/repository.git";
var path = @"C:\Temp\some-repository";
LibGit2Sharp.Repository.Clone(url, path, new LibGit2Sharp.CloneOptions { CredentialsProvider = MyCredentialsProvider });
}
private Credentials MyCredentialsProvider(string url, string usernameFromUrl, SupportedCredentialTypes types)
{
var sshDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".ssh");
return new LibGit2Sharp.SshUserKeyCredentials()
{
Username = usernameFromUrl,
Passphrase = string.Empty,
PublicKey = Path.Combine(sshDir, "id_rsa.pub"),
PrivateKey = Path.Combine(sshDir, "id_rsa"),
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With