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

Algorithm negotiation fail #82

@ymcymc

Description

@ymcymc

Exception: "git@github.com: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("git@github.com:username/project.git")
.Call();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions