Trying to put together a sample project cloning a repository (hosted in GOGS) using SSH and am getting the following error:
Failed to start SSH session: Unable to exchange encryption keys
I'm on windows, the keys are generated using ssh-keygen, and I have the following nuget packages referenced
- LibGit2Sharp 0.25.3
- LibGit2Sharp.NativeBinaries 1.0.235
- LibGit2Sharp-SSH 1.0.22
- LibGit2Sharp-SSH.NativeBinaries 1.0.14
We're able to pull files from a test bit bucket account, but not from the GOGS repository url, using code like the following (the same keys have been uploaded to both accounts).
var co = new CloneOptions
{
CredentialsProvider = (_url, _user, _cred) => new SshUserKeyCredentials()
{
PrivateKey = @"C:\Users\username\.ssh\keygen\gen",
PublicKey = @"C:\Users\username\.ssh\keygen\gen.pub",
Passphrase = string.Empty,
Username = "git"
},
};
Repository.Clone("ssh://git@<site_url>:443/Project/Project.git ", TestPath, co);
I'd also add that we can clone from both urls using a variety of git clients (git exe, tortoise git, gitkraken) without issue. Also we can connect over https with username and password with LibGit2Sharp.
Things I've tried so far:
- Generating new keys with ssh-keygen
- Converting the private key file to openssh using puttygen > Conversions > Export OpenSSH
- Converting the private key to PEM format using "openssl rsa -in key-out key.pem"
- Made sure that the Public key was single line, starting with type, followed by base64 key, no comment at the end