Issue cloning repository over SSH
See original GitHub issueReproduction steps
I have a bug when I try to clone repository over SSH key.
What I did?
public static string passphrase = "123";
public static string sshDir = "C:\\Users\\HereIsMyUserName\\Desktop\\keys\\.ssh";
CloneOptions options = new CloneOptions
{
Checkout = false,
CredentialsProvider = (url, user, cred) => new SshUserKeyCredentials()
{
PrivateKey = sshDir + "id_rsa",
Passphrase = passphrase,
PublicKey = sshDir + "id_rsa.pub",
Username = "git"
}
};
public string CreateUniqueTempDirectory()
{
var uniqueTempDir = Path.GetFullPath(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));
Directory.CreateDirectory(uniqueTempDir);
return uniqueTempDir;
}
private void button1_Click(object sender, EventArgs e)
{
try
{
Repository.Clone(sshURL, CreateUniqueTempDirectory(), options);
}
catch (Exception)
{
throw;
}
}
What I get?
I get exception:
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at LibGit2Sharp.Core.NativeMethods.git_clone(git_repository*& repo, String origin_url, FilePath workdir_path, GitCloneOptions& opts) at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts) in C:\Users\DVasilje\Downloads\libgit2sharp-ssh-master\libgit2sharp-ssh-master\LibGit2Sharp\Core\Proxy.cs:line 356 at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options) in C:\Users\DVasilje\Downloads\libgit2sharp-ssh-master\libgit2sharp-ssh-master\LibGit2Sharp\Repository.cs:line 732 at libgit2sharpSSHtest.Form1.button1_Click(Object sender, EventArgs e) in C:\VS2019\sshtest\libgit2sharpSSHtest\libgit2sharpSSHtest\Form1.cs:line 51 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm)
###How did I created my SSH key?
$ ssh-keygen -t rsa -C “your_email@example.com” inside gitBash, like GitHub recommended it
Version of LibGit2Sharp
(both 1.0.22 of LibGit2Sharp-SSH and LibGit@Sharp-SSH-updated-libssh2 version 1.0.25 )
Operating system(s) tested; .NET runtime tested
Windows 10, .NET 4.7.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top GitHub Comments
I don’t know why the status is still open, @ethomson clearly stated that libgit2 developers are not implementing nor will in future implement SSH, and therefore we should do it on our own. Sadge
whats the status of this?