Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Algorithm negotiation fail #82

Open
ymcymc opened this issue Nov 27, 2018 · 0 comments
Open

Algorithm negotiation fail #82

ymcymc opened this issue Nov 27, 2018 · 0 comments

Comments

@ymcymc
Copy link

ymcymc commented Nov 27, 2018

Exception: "[email protected]:username/project.git: Algorithm negotiation fail"
Code:

public class CustomConfigSessionFactory : JschConfigSessionFactory
{
public string PrivateKey { get; set; }
public string PublicKey { get; set; }

protected override void Configure(OpenSshConfig.Host hc, Session session)
{
     var config = new Properties();
     config["StrictHostKeyChecking"] = "no";
     config["PreferredAuthentications"] = "publickey";
     session.SetConfig(config);

     var jsch = this.GetJSch(hc, FS.DETECTED);
     jsch.AddIdentity("KeyPair", Encoding.UTF8.GetBytes(PrivateKey), Encoding.UTF8.GetBytes(PublicKey), Encoding.UTF8.GetBytes("netbrain"));
}

}

var customConfigSessionFactory = new CustomConfigSessionFactory();
customConfigSessionFactory.PrivateKey = File.ReadAllText(@"D:\id_rsa");
customConfigSessionFactory.PublicKey = File.ReadAllText(@"D:\id_rsa.pub");

NGit.Transport.JschConfigSessionFactory.SetInstance(customConfigSessionFactory);
var git = NGit.Api.Git.CloneRepository()
.SetDirectory(new Sharpen.FilePath(@"d:\abcde"))
.SetURI("[email protected]:username/project.git")
.Call();

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant