Skip to content

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

Closed
@semionenko

Description

@semionenko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions