1

I'm having a miserable time trying to integrate GitHub with my iOS Xcode project. Something got screwed up, so I decided to just start from scratch. I'm using Xcode version 11.0. The problems seem to have started back when I upgraded from version 9.0.

I have GitHub setup in Xcode using SSH key, but I have also tried with HTTPS.

enter image description here

I used rm -rf .git to remove the existing repositories. Then used Source Control / Create Git Repositories... in Xcode to recreate them.

It created the local repositories as expected and I also created the remote ones on GitHub.

enter image description here

However, when I try to commit or push, I get the following error:

enter image description here

enter image description here

If I try the Fetch and Refresh Status option, I get the following:

enter image description here

The error messages aren't particularly enlightening. I'm not sure what to try next. I have tried manually creating the remote repositories right on GitHub, as well as letting Xcode create them, but I get the same result. I even uninstalled and re-installed Curl. Is there something obvious I should be doing, a log I can check, or some other way to get any useful info about this? Thanks.

EDIT: Here are the results from the ssh call suggested.

Black-Mac-Pro:~ sheldon$ ssh -i ~/.ssh/id_github -Tv git@github.com
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /Volumes/PEGASUS/Users/sheldon/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to github.com port 22.
debug1: Connection established.
debug1: identity file /Volumes/PEGASUS/Users/sheldon/.ssh/id_github type 0
debug1: identity file /Volumes/PEGASUS/Users/sheldon/.ssh/id_github-cert type -1
debug1: identity file /Volumes/PEGASUS/Users/sheldon/.ssh/Y2goAWS.pem type -1
debug1: identity file /Volumes/PEGASUS/Users/sheldon/.ssh/Y2goAWS.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version babeld-a81b9751
debug1: no match: babeld-a81b9751
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Volumes/PEGASUS/Users/sheldon/.ssh/known_hosts:4
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: /Volumes/PEGASUS/Users/sheldon/.ssh/id_github RSA SHA256:urvuR2AnjonUD93eMeBsznrm+e/C0u3kDAiFGFFHT2U explicit
debug1: Will attempt key: /Volumes/PEGASUS/Users/sheldon/.ssh/Y2goAWS.pem  explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Volumes/PEGASUS/Users/sheldon/.ssh/id_github RSA SHA256:urvuR2AnjonUD93eMeBsznrm+e/C0u3kDAiFGFFHT2U explicit
debug1: Server accepts key: /Volumes/PEGASUS/Users/sheldon/.ssh/id_github RSA SHA256:urvuR2AnjonUD93eMeBsznrm+e/C0u3kDAiFGFFHT2U explicit
Enter passphrase for key '/Volumes/PEGASUS/Users/sheldon/.ssh/id_github': 
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([140.82.113.3]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = en_CA.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi lastmboy! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2684, received 2228 bytes, in 0.1 seconds
Bytes per second: sent 26179.5, received 21731.7
debug1: Exit status 1


Black-Mac-Pro:~ sheldon$ git ls-remote git@github.com:lastmboy/y2go.git
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

EDIT (10-Oct-2019):

Now I'm getting the following:

Black-Mac-Pro:y2go sheldon$ ssh -i ~/.ssh/id_rsa git@github.com
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Volumes/PEGASUS/Users/sheldon/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/Volumes/PEGASUS/Users/sheldon/.ssh/id_rsa": bad permissions
git@github.com: Permission denied (publickey).
Lastmboy
  • 1,849
  • 3
  • 21
  • 39

1 Answers1

1

curl should not be involved if you are using SSH.

Check first if your SSH key works and if GitHub recognizes you (meaning you have registered the public key on your GitHub profile)

ssh -i ~/.ssh/id_github -Tv git@github.com

(assuming here your id_github and id_github.pub files are in ~/.ssh/)
You should see a Welcome message at the end.

If not, recreate the key using the old PEM format:

ssh-keygen -t rsa -C "xxx@yyyy.com" -m PEM -P "" -f ~/.ssh/id_github2

Then check the remote URL exists: git ls-remote git@github.com:<YourGitHubAccount>/<YourRepo>

Only then can you test XCode.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, @VonC. I tried you suggestions and posted the results above. I got the permission denied error, so I created a new key pair and pushed the public one to GitHub. However, I still get the same permission denied error. At least you have me pointed in the right direction, so I'll keep working at it. – Lastmboy Oct 10 '19 at 04:11
  • @Lastmboy Did you publish your public key to your GitHub profile (as in https://help.github.com/en/articles/adding-a-new-ssh-key-to-your-github-account)? If yes, what command did you type locally? – VonC Oct 10 '19 at 05:00
  • I had just used Xcode to push it up and verify it. However, just for fun, I deleted all public keys and manually copied it as per your link. Still get the same error, though. – Lastmboy Oct 10 '19 at 20:09
  • @Lastmboy Make sure to copy the public key, and as one line. if that public key is called `~/.ssh/id_github2.pub`, your test will be, from command-line, `ssh -i ~/.ssh/id_github2 git@github.com` – VonC Oct 10 '19 at 20:11
  • I updated the question with my latest response. Do I need to be manually changing the permissions on the keys after they are created? – Lastmboy Oct 10 '19 at 20:36
  • @Lastmboy Yes, as I described in https://stackoverflow.com/a/13428529/6309 – VonC Oct 10 '19 at 20:39
  • I think something is screwed up on my Mac Pro. The key seems fine. I manually copied the project to my MacBook Pro, wiped out the repositories and re-created them all, and can push/pull/commit with the remotes without problem. I wiped out the folder on my Mac Pro and cloned the repo from the one I pushed up with the MacBook. No matter what I do on the Mac Pro, I get "multiple unknown errors occurred". Is this something I could fix by removing and re-installing anything (e.g. git, Xcode, other)? – Lastmboy Oct 24 '19 at 18:08
  • @Lastmboy Can you compare git version and git config -l on both Macs? Is there any difference? – VonC Oct 24 '19 at 19:15
  • I'm just using the git installed with Xcode. However, I discovered I had Xcode 11.1 on the MacBook and version 11.0 on the Mac Pro. I toasted it and installed 11.1. I'm getting further. I can now `Fetch and Refresh Status`. However, I tried a Pull and I get the message "An unknown error occurred. No merge base found (-3)." – Lastmboy Oct 24 '19 at 20:33
  • @Lastmboy What does a git status return in the local repo where you are doing, with XCode, a pull? – VonC Oct 24 '19 at 21:46
  • git status result: `Black-Mac-Pro:y2go sheldon$ git status Refresh index: 100% (4646/4646), done. On branch master nothing to commit, working tree clean` – Lastmboy Oct 25 '19 at 02:15
  • @Lastmboy Is is the same kind of status on the other Mac? Or is the refresh 4646 an indication that this local repo is much larger than needed? – VonC Oct 25 '19 at 04:41
  • I managed to get it working. Just had to create a new branch. I believe the initial problem was my public key, so your solution worked. Thanks for all your help. – Lastmboy Oct 26 '19 at 01:17