Clone a project from github/gitlab by SSH with an error
semionenko opened this issue · 3 comments
I see the error:
Error Domain=GTGitErrorDomain Code=-1 "Failed to start SSH session: Unable to exchange encryption keys".
I've have simple code for clone project from github:
GTCredentialProvider *credentialProvider = [GTCredentialProvider providerWithBlock:^GTCredential * _Nonnull(GTCredentialType type, NSString * _Nonnull URL, NSString * _Nonnull userName)
{
// the code newer called now
NSError *error;
GTCredential *credential;
GPSSHKey *sshKey = [GPObjects fetchSSHKeyWithType:SSHKeyTypeGitHub];
if (type & GTCredentialTypeSSHKey && sshKey != nil)
{
NSString *username = userName.length > 0 ? userName : hostingProvider.username;
credential = [GTCredential credentialWithUserName:username publicKeyURL:sshKey.publicKeyStorageURL privateKeyURL:sshKey.privateKeyStorageURL passphrase:sshKey.passphrase error:&error];
}
else if (type & GTCredentialTypeUserPassPlaintext)
{
if (hostingProvider.username.length > 0 && hostingProvider.password.length > 0)
{
credential = [GTCredential credentialWithUserName:hostingProvider.username password:hostingProvider.password error:&error];
}
else if (sshKey != nil)
{
NSString *username = userName.length > 0 ? userName : hostingProvider.username;
if (!username) {
username = @"";
}
credential = [GTCredential credentialWithUserName:username publicKeyURL:sshKey.publicKeyStorageURL privateKeyURL:sshKey.privateKeyStorageURL passphrase:sshKey.passphrase error:&error];
}
}
return credential;
}];
[options setObject:credentialProvider forKey:GTRepositoryCloneOptionsCredentialProvider];
[options setObject:@(YES) forKey:GTRepositoryCloneOptionsCloneLocal];
GTRepository *repository = [GTRepository cloneFromURL:gitURL toWorkingDirectory:localURL options:options error:&error transferProgressBlock:^(const git_transfer_progress * _Nonnull progress, BOOL * _Nonnull stop) {}];
Could you help me please? I don't know why it happens. A pair of ssh keys exist and public key is used in github. I don't understand what I should do in the project / settings to get rid of this.
Thanks.
I'll infer you're on iOS, if that's not the case, please be more specific.
You need to update to a more recent Objective-Git : the libssh2 version we're packaging in the current release doesn't handle the new cipher suites that GitHub started enforcing in February.
Yes, i've used iOS. Could you please clarify to which version I need to upgrade?