问题描述
commands.pull返回无法启动SSH会话:无法交换加密密钥
我的代码如下: ...
private Credentials CredentialsHandler()
{
var sshDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),".ssh");
return new SshUserKeyCredentials()
{
Username = "gitusername",Passphrase = string.Empty,PublicKey = Path.Combine(sshDir,"id_rsa.pub"),PrivateKey = Path.Combine(sshDir,"id_rsa")
};
}
public Response GitPull()
{
var responseModel = new Response();
try
{
var response = CheckoutBranch();
if (!response.Status) return responseModel;
using (var repository = _utility.GetRepository(_directoryInfo.FullName))
{
// Credential information to fetch
PullOptions options = new PullOptions();
options.FetchOptions = new FetchOptions();
options.FetchOptions.CredentialsProvider = (url,usernameFromUrl,types) => CredentialsHandler;
_logger.Loginformation("fetched all the commits successfully from the branch");
// User information to create a merge commit
var signature = repository.Config.BuildSignature(DateTimeOffset.Now);
// Pull
var result = Commands.Pull((Repository)repository,signature,options);
responseModel.Status = result.Status == MergeStatus.UpToDate;
}
return responseModel;
}
catch (Exception ex)
{
}
}
请任何人帮助我。感谢您的帮助! ...
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)