개인 키와의 세션 부분 연결에는 문제가 없습니다. 그러나 내가 git Clone을 할 때 'Auth Fail'오류가 발생합니다. 어떻게 묶어서 묶고, 연결된 세션을 git clone과 함께 작동시킬 수 있습니까? .NET 4.0에서 NGIT를 사용하고 있지만 JGIT가 거의 동일하므로이 점이 중요하지 않다고 생각합니다.NGIT/JGIT/Git # SSH 개인 키를 사용하여 세션을 복제하는 GiT 저장소
아이디어가 있으십니까?
감사합니다 개빈
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();
Credentials Provider에 도움이되는지 확인하기 위해 추가했습니다. CloneCommand clone = Git.CloneRepository() .SetCredentialsProvider (새 CustomCredentialsProvider()) .SetURI (gitAddress) .SetDirectory (folderToSave); clone.Call(); – Gavin
어떤 버전의 NGit를 사용하고 있습니까? 내가 알아챈 한 가지는 NuGet에서 얻은 NGit이 꽤 오래되었습니다 (2011 년 이전). 따라서이 문제를 해결하는 버그 수정에 뒤처질 수 있습니다. 내 경우에는 전혀 연결할 수 없었지만 NGit의 최신 버전을 [github from latest] (https://github.com/mono/ngit)로 업데이트했습니다. –