Unfortunately, LibGit2Sharp does not include the necessary crypto libraries out of the box ( https://github.com/libgit2/libgit2sharp/issues/255#issuecomment-212580185 ).
Use the LibGit2Sharp-SSH NuGet Package (fork).
private void Run() { var url = "ssh:// username@gitblit.example.com /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"), }; }
source share