【问题标题】:Can't connect github repository using ssh protocol无法使用 ssh 协议连接 github 存储库
【发布时间】:2020-03-24 06:04:31
【问题描述】:

我正在尝试使用 ssh 协议连接到远程 github 存储库。
之后
git remote add origin ssh://username@github.com/foo/project.git
git 远程显示来源
产量:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

ssh -vT git@github.com 日志:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /home/inna/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [999.99.999.9] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/inna/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/inna/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/inna/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/inna/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/inna/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/inna/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/inna/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/inna/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1: Remote protocol version 2.0, remote software version babeld-0de80d89
debug1: no match: babeld-0de80d89
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
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:hhgkhkjhjkhjkhjkhjkhjkhkjhjkhjkhjk
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/inna/.ssh/known_hosts:1
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: 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 RSA public key: /home/inna/.ssh/jj
debug1: Server accepts key: pkalg ssh-rsa blen 535
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([999.99.999.9]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LC_PAPER = ru_RU.UTF-8
debug1: Sending env LC_ADDRESS = ru_RU.UTF-8
debug1: Sending env LC_MONETARY = ru_RU.UTF-8
debug1: Sending env LC_NUMERIC = ru_RU.UTF-8
debug1: Sending env LC_TELEPHONE = ru_RU.UTF-8
debug1: Sending env LC_IDENTIFICATION = ru_RU.UTF-8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_MEASUREMENT = ru_RU.UTF-8
debug1: Sending env LC_TIME = ru_RU.UTF-8
debug1: Sending env LC_NAME = ru_RU.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi Inna! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3888, received 2484 bytes, in 0.3 seconds
Bytes per second: sent 11319.0, received 7231.6
debug1: Exit status 1

到同一个项目的 https 连接工作得很好,但我每次访问远程存储库时都必须登录(顺便问一下,我能以某种方式包抄它吗?)。
SSH 密钥存在并且用户可以访问它们。 谁能告诉我是什么问题?

【问题讨论】:

    标签: git github ssh


    【解决方案1】:
    git remote add origin ssh://username@github.com/foo/project.git
    

    这不应使用username,而应使用git,如:

    git remote add origin ssh://git@github.com/foo/project.git
    

    【讨论】:

      【解决方案2】:

      您似乎没有将 SSH 密钥添加到您的 GitHub 帐户。看看这个Doc 怎么做。

      【讨论】:

      • 是的,我确实将我的公钥添加到了我的 git 帐户中,从日志来看没问题。
      【解决方案3】:

      假设您已将正确的公钥添加到您的 GitHub 帐户,并且您对远程存储库拥有适当的权限,我猜这个问题与您的私钥有关。

      您应该确保您的私钥被命名为id_rsa,或者您有ssh-agent 正在运行并且已添加密钥。如果您想运行 ssh-agent 并添加密钥,请尝试以下操作:

      $ eval `ssh-agent`
      $ ssh-add /path/to/private_key
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-10-30
        • 2015-04-20
        • 1970-01-01
        • 2010-09-27
        • 1970-01-01
        • 2019-10-03
        • 1970-01-01
        相关资源
        最近更新 更多