mwcbrent

Q: XCode Service Bots Private Key Issue

I have scoured the internet in order to find a solution.  I am creating a bot to test and built my iOS project.  When running an integration, after pulling down the code I am running into an error.  I have found a few guides online on how to get this setup properly and many of them include a step of copying my certificate + keys for my development and distribution profiles into the System (rather than login) in Keychain Assistant.  I have completed this, restarted, deleted my bots (and repositories).  I am working with a brand new developer account.  I am running OS X Server on the same machine I develop with and the certificates work fine when I build with XCode.  I also am using a separate Scheme (duplicate of my normal build scheme)

 

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSCredentialServerHTTPClient.m:174 77caa310 +0ms] Got a response to a download credential request <NSHTTPURLResponse: 0x7fdff24537d0> { URL: https://127.0.0.1:2012/ } { status code: 200, headers { "Accept-Ranges" = bytes; "Content-Length" = 798; Date = "Fri, 21 Mar 2014 22:23:07 GMT"; "X-Apple-Credential-credentialType" = sshKey; } }

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSCredentialServerHTTPClient.m:175 77caa310 +0ms] Got credential with type sshKey

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSCredentialServerHTTPClient.m:189 77caa310 +0ms] Mapping credential to an XCSCredential instance

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSCredentialServerHTTPClient.m:195 77caa310 +0ms] Dealing with an SSH key credential, attempting to initialize an XCSCredentialSSHKey

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSCredentialServerHTTPClient.m:204 77caa310 +0ms] Got a credential object <XCSCredentialSSHKey: 0x7fdff2454e50> of type sshKey

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSCredentialOperation.m:109 77caa310 +0ms] Credential callback fired credential = <XCSCredentialSSHKey: 0x7fdff2454e50>, error = (null)

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSCredentialOperation.m:117 77caa310 +0ms] Processing credential <XCSCredentialSSHKey: 0x7fdff2454e50> for downloadToken !0R<7Xe9O-V.~,Z-n?$sI1p@E|Ok"9u(LY=I[oGFplI}Ko#\r)(>G6&n<D;rt/D#

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSCredentialSSHKey.m:93 77caa310 +0ms] XCSCredentialSSHKey: credential does not have a type, defaulting to id_rsa

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSCredentialSSHKey.m:97 77caa310 +0ms] XCSCredentialSSHKey: credential type is id_rsa

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Error>: [XCSCredentialSSHKey.m:105 77caa310 +0ms] XCSCredentialSSHKey: private key is missing from the credential

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Error>: [XCSOperation.m:33 77caa310 +0ms] Error Domain=XCSBuildServiceDomain Code=-1 "applyToPath failed for credential <XCSCredentialSSHKey: 0x7fdff2454e50> and path /Library/Server/Xcode/Data/BotRuns/BotRun-25cece4f-6a65-4d9b-9a4e-3216c5a93ffa. bundle/credentials/ef3b3fd6-3c72-425e-8dd1-1e3bb8cc316b. Reason: XCSCredentialSSHKey: private key is missing from the credential" UserInfo=0x7fdff24545e0 {NSLocalizedDescription=applyToPath failed for credential <XCSCredentialSSHKey: 0x7fdff2454e50> and path /Library/Server/Xcode/Data/BotRuns/BotRun-25cece4f-6a65-4d9b-9a4e-3216c5a93ffa. bundle/credentials/ef3b3fd6-3c72-425e-8dd1-1e3bb8cc316b. Reason: XCSCredentialSSHKey: private key is missing from the credential}

Mar 21 17:23:07 Brent-Sanderss-iMac.local xcsbuildd[4113] <Debug>: [XCSOperation.m:28 77caa310 +0ms] Cancelling operation: XCSCredentialOperation

iMac, OS X Server

Posted on Mar 21, 2014 3:33 PM

Close

Q: XCode Service Bots Private Key Issue

  • All replies
  • Helpful answers

  • by xaphod,

    xaphod xaphod Mar 26, 2014 3:51 AM in response to mwcbrent
    Level 1 (0 points)
    Mar 26, 2014 3:51 AM in response to mwcbrent

    I have this same issue. I tried for 2 hours and gave up trying to have xcode bots authenticate to remote GitHub repos via SSH key. It just doesn't work.

     

    Here are some useful things to try, in case it helps you:

    - the keys that xcode generates itself have some wonky passphrase in them, so generate your own instead

    - use ssh-add -K to add it to the keychain (login keychain). I did not try moving this to system keychain -- oh maybe that'd be a good thing to try actually.

     

    ssh-keygen -t rsa -C "email address used at github"

    ssh-add ./id_rsa

    ssh-add -K ./id_rsa

    (add .pub to github ssh keys)

  • by mwcbrent,

    mwcbrent mwcbrent Mar 26, 2014 6:01 AM in response to xaphod
    Level 1 (0 points)
    Mar 26, 2014 6:01 AM in response to xaphod

    I did actually solve this issue.  I found that the server would generate a new key each time I added a repo.  Since my project uses a submodule it would generate two new keys (one for each repository).  I tried setting the keys to a single key but it didn't seem to work.  I just had to add the new keys each time to my github account.

     

    I would say that this was the first bump of many I ran into.  I ended up abandoning this process in favor of Jenkins.

  • by xaphod,

    xaphod xaphod Mar 26, 2014 6:23 AM in response to mwcbrent
    Level 1 (0 points)
    Mar 26, 2014 6:23 AM in response to mwcbrent

    Well, you win: no matter what keys I add to github, I always get either private key missing, or, authentication just fails. Did use user=git or user=emailaddress or user=gitusername ?

  • by mwcbrent,

    mwcbrent mwcbrent Mar 26, 2014 7:06 AM in response to xaphod
    Level 1 (0 points)
    Mar 26, 2014 7:06 AM in response to xaphod

    I used user = git

     

    I would add the public key to the keys on my account and that would resolve this issue. 

  • by xaphod,

    xaphod xaphod Apr 2, 2014 2:26 AM in response to mwcbrent
    Level 1 (0 points)
    Apr 2, 2014 2:26 AM in response to mwcbrent

    I have tried user=git, and copying the public key generated by Server->Xcode up to github. No matter what I do, it fails... here is what I see:

     

    1) the first time after generating new keys in Server->XCode and putting the public key on Github, the bot returns this error. Note that it gets past the part in 2) where the private key is missing:

     

    pr  2 11:12:01 build.xyz xcsbuildd[56626] <Debug>: [XCSCheckoutOperation.m:543 78937310 +0ms] cloneError: Error Domain=CSBotSCMAction Code=-1000 "Cloning into 'https_github_com_my_repo'... remote: Invalid username or password. fatal: Authentication failed for 'https://git@github.com/my/repo///git@github.com/my/repo/' " UserInfo=0x7fd229e1a7b0 {NSLocalizedDescription=Cloning into 'https_github_com_my_repo'... remote: Invalid username or password. fatal: Authentication failed for 'https://git@github.com/my/repo///git@github.com/my/repo/' }

     

    2) if I try again, it doesn't get that far anymore, it starts saying this instead:

     

    Apr  2 11:13:16 build.xyz xcsbuildd[56939] <Debug>: [XCSCredentialSSHKey.m:93 78937310 +0ms] XCSCredentialSSHKey: credential does not have a type, defaulting to id_rsa

    Apr  2 11:13:16 build.xyz xcsbuildd[56939] <Debug>: [XCSCredentialSSHKey.m:97 78937310 +0ms] XCSCredentialSSHKey: credential type is id_rsa

    Apr  2 11:13:16 build.xyz xcsbuildd[56939] <Error>: [XCSCredentialSSHKey.m:105 78937310 +0ms] XCSCredentialSSHKey: private key is missing from the credential

    Apr  2 11:13:16 build.xyz xcsbuildd[56939] <Error>: [XCSOperation.m:33 78937310 +0ms] Error Domain=XCSBuildServiceDomain Code=-1 "applyToPath failed for credential <XCSCredentialSSHKey: 0x7fd4d2803350> and path /Library/Server/Xcode/Data/BotRuns/BotRun-6287c659-05d6-4a19-97c8-3fe2453426f1. bundle/credentials/cfebdc3c-8283-4532-9603-78324c11b1cc. Reason: XCSCredentialSSHKey: private key is missing from the credential" UserInfo=0x7fd4d28141d0 {NSLocalizedDescription=applyToPath failed for credential <XCSCredentialSSHKey: 0x7fd4d2803350> and path /Library/Server/Xcode/Data/BotRuns/BotRun-6287c659-05d6-4a19-97c8-3fe2453426f1. bundle/credentials/cfebdc3c-8283-4532-9603-78324c11b1cc. Reason: XCSCredentialSSHKey: private key is missing from the credential}

    Apr  2 11:13:16 build.xyz xcsbuildd[56939] <Debug>: [XCSOperation.m:28 78937310 +0ms] Cancelling operation: XCSCredentialOperation

     

     

    This is really frustrating: any help would be really appreciated.

    I have not tried copying key into keychain->system etc, do I need to?

  • by xaphod,

    xaphod xaphod Apr 2, 2014 2:43 AM in response to xaphod
    Level 1 (0 points)
    Apr 2, 2014 2:43 AM in response to xaphod

    OK, one lesson learned: in Server->Xcode->repositories, never ever edit a remote repository, especially if you are changing things with SSH keys. It is buggy as **** and breaks things. Just delete the repo and remake it every time you want to change thigns, and things are far more consistent.

     

    I believe my issue stems from the fact that the repo I want to pull is from a private github organization of which i'm a member. So instead of me needing to add the ssh key to my personal user's github ssh keys, it needs to be added to the organization's ssh keys.

  • by megamegamega,

    megamegamega megamegamega Apr 28, 2014 5:53 PM in response to xaphod
    Level 1 (0 points)
    Apr 28, 2014 5:53 PM in response to xaphod

    Just like to echo xaphod. When creating a repo from scratch I was able to successfully modify the keys. Editing repos seemed to break it every time (missig private keys, settings not changed).