会话部分用私钥连接,没问题。但是,当我执行 git Clone 时,它会给出错误“身份验证失败”。如何包装、绑定或使连接的会话与 git clone 一起工作。我在 .NET 4.0 下使用 NGIT,但不要认为这很重要,因为 JGIT 几乎相同。
有任何想法吗 ?
谢谢加文
        JSch jsch = new JSch();
        Session session = jsch.GetSession(gUser, gHost, 22);
        jsch.AddIdentity(PrivateKeyFile); // If I leave this line out, the session fails to Auth. therefore it works.
        Hashtable table = new Hashtable();
        table["StrictHostKeyChecking"] = "no"; // this works
        session.SetConfig(table);
        session.Connect(); // the session connects.
        URIish u = new URIish();
        u.SetPort(22);
        u.SetHost(gHost);
        u.SetUser(gUser);            
        NGit.Transport.JschSession jschSession = new JschSession(session,u );
        if (session.IsConnected())
        {
            try
            {
                CloneCommand clone = Git.CloneRepository()
                    .SetURI(gitAddress)
                    .SetDirectory(folderToSave);                                        
                clone.Call();                  
             //   MessageBox.Show(Status, gitAddress, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                // AUth Fail..... ????
            }
        }
        else
        {
            session.Disconnect();
        }
        session.Disconnect();