How to use libgit2sharp with ssh-transport-protocol?

When I use libgit2sharp in a project to clone a repository using ssh transport protocol like

git@github.com :libgit2/libgit2sharp.git 

Throws an exception, says: "This transport is not implemented. Sorry"

How can I clone a repository using ssh transport protocol using libgit2sharp?

+6
source share
2 answers

Unfortunately, the Ssh protocol is not yet supported. Currently, the protocols are git:// (read-only) and http[s]:// .

However, in the end it will be using the libssh2 library.

Signing issue # 255 notifications will keep you updated on the progress made with this feature.

Update:

Work is underway in libgit2 (see PR # 2428 ), which should help us make LibGit2Sharp available more likely to handle the ssh protocol than later.

Update 2:

PR # 852 is working to make ssh available for LibGit2Sharp

+6
source

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"), }; } 
+1
source

Source: https://habr.com/ru/post/970888/


All Articles