简体   繁体   English

无法使用 ssh 协议连接 github 存储库

[英]Can't connect github repository using ssh protocol

I'm trying to connect to remote github repository using ssh protocol.我正在尝试使用 ssh 协议连接到远程 github 存储库。
After
git remote add origin ssh://username@github.com/foo/project.git git remote add origin ssh://username@github.com/foo/project.git
git remote show origin git远程显示原点
yields:产量:

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 log: 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

The https connection to the same project works just fine but I have to log in every time I address the remote repository (by the way, can I outflank it somehow?).到同一个项目的 https 连接工作正常,但每次访问远程存储库时我都必须登录(顺便说一下,我可以以某种方式包抄它吗?)。
Ssh keys exist and the user have access to them. SSH 密钥存在并且用户可以访问它们。 Could anyone tell what's the problem please?谁能告诉我有什么问题吗?

It seems you didn't add your SSH key to your GitHub account.您似乎没有将 SSH 密钥添加到您的 GitHub 帐户。 See this Doc how to do that.请参阅此Doc如何做到这一点。

Assuming that you have added the correct public keys to your GitHub account and that you have the proper rights on the remote repository, my guess is that the issue is related to your private key.假设您已将正确的公钥添加到您的 GitHub 帐户,并且您对远程存储库拥有适当的权限,我的猜测是问题与您的私钥有关。

You should ensure that either your private key is named id_rsa or that you have the ssh-agent running and the key was added it.您应该确保您的私钥被命名为id_rsa或者您正在运行ssh-agent并添加了密钥。 If you want to run the ssh-agent and add the keys, try the following:如果要运行 ssh-agent 并添加密钥,请尝试以下操作:

$ eval `ssh-agent`
$ ssh-add /path/to/private_key
git remote add origin ssh://username@github.com/foo/project.git

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM