The session part connections with the private key, no problem. However when I do a git Clone, it gives the error 'Auth Fail'. How do I wrap, bind or make the connected session work with git clone. I'm using NGIT under .NET 4.0, but don't think this matters as JGIT is pretty much the same.
Any ideas ?
Thanks Gavin
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();