Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone a project from github/gitlab by SSH with an error #647

Closed
semionenko opened this issue Mar 16, 2018 · 3 comments
Closed

Clone a project from github/gitlab by SSH with an error #647

semionenko opened this issue Mar 16, 2018 · 3 comments

Comments

@semionenko
Copy link

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.

@tiennou
Copy link
Contributor

tiennou commented Mar 16, 2018

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.

@semionenko
Copy link
Author

Yes, i've used iOS. Could you please clarify to which version I need to upgrade?

@tiennou
Copy link
Contributor

tiennou commented Mar 19, 2018

We're currently waiting on libgit2 in #645. As a stopgap measure, you could use master directly in the meantime (it's tracking 0.27.rc-1), I don't think there were many breaking changes between 0.13 and almost-0.14, but YMMV.

I'll close this, feel free to stay tuned in #645.

@tiennou tiennou closed this as completed Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants