【问题标题】:Curl error when trying to push from Xcode to GitHub尝试从 Xcode 推送到 GitHub 时出现卷曲错误
【发布时间】:2020-02-06 08:23:40
【问题描述】:

我在尝试将 GitHub 与我的 iOS Xcode 项目集成时很痛苦。事情搞砸了,所以我决定从头开始。我正在使用 Xcode 11.0 版。当我从 9.0 版升级时,问题似乎又开始了。

我在 Xcode 中使用 SSH 密钥设置了 GitHub,但我也尝试过使用 HTTPS。

我使用rm -rf .git 删除现有存储库。然后在 Xcode 中使用Source Control / Create Git Repositories... 重新创建它们。

它按预期创建了本地存储库,我还在 GitHub 上创建了远程存储库。

但是,当我尝试 commitpush 时,我收到以下错误:

如果我尝试Fetch and Refresh Status 选项,我会得到以下信息:

错误消息并不是特别有启发性。我不确定下一步该尝试什么。我尝试在 GitHub 上手动创建远程存储库,以及让 Xcode 创建它们,但我得到了相同的结果。我什至卸载并重新安装了 Curl。有什么明显的我应该做的事情,我可以检查的日志,或者其他方式来获取任何有用的信息吗?谢谢。

编辑: 以下是建议的 ssh 调用的结果。

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.

编辑(2019 年 10 月 10 日):

现在我得到以下信息:

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).

【问题讨论】:

    标签: xcode git github version-control repository


    【解决方案1】:

    如果您使用 SSH,则不应涉及 curl。

    首先检查您的 SSH 密钥是否有效,以及 GitHub 是否能够识别您(意味着您已在 GitHub 个人资料中注册了公钥)

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

    (假设您的 id_githubid_github.pub 文件在 ~/.ssh/ 中)
    您应该会在最后看到一条欢迎消息。

    如果没有,请使用old PEM format 重新创建密钥:

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

    然后检查远程URL是否存在:git ls-remote git@github.com:&lt;YourGitHubAccount&gt;/&lt;YourRepo&gt;

    只有这样你才能test XCode

    【讨论】:

    • 谢谢,@VonC。我尝试了您的建议并在上面发布了结果。我得到了权限被拒绝的错误,所以我创建了一个新的密钥对并将公共密钥对推送到 GitHub。但是,我仍然得到相同的权限被拒绝错误。至少你让我指出了正确的方向,所以我会继续努力。
    • @Lastmboy 您是否将您的公钥发布到您的 GitHub 个人资料中(如help.github.com/en/articles/…)?如果是,您在本地输入了什么命令?
    • 我刚刚用Xcode推上去验证了一下。但是,只是为了好玩,我删除了所有公钥并根据您的链接手动复制了它。但是,仍然会出现同样的错误。
    • @Lastmboy 确保复制公钥,并作为一行。如果该公钥称为~/.ssh/id_github2.pub,您的测试将是,从命令行,ssh -i ~/.ssh/id_github2 git@github.com
    • 我用我的最新回复更新了这个问题。是否需要在创建密钥后手动更改它们的权限?
    猜你喜欢
    • 2016-03-18
    • 2012-11-06
    • 2023-03-16
    • 2012-10-29
    • 2016-12-30
    • 1970-01-01
    • 2016-08-02
    • 2020-01-08
    • 2018-02-27
    相关资源
    最近更新 更多