首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法使用ssh协议连接github存储库

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

Stack Overflow用户
提问于 2020-03-24 06:04:31
回答 3查看 570关注 0票数 0

我正在尝试使用ssh协议连接到远程github存储库。

之后

git远程添加源ssh://username@github.com/foo/project.git

git远程显示原点

产量:

代码语言:javascript
运行
复制
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日志:

代码语言:javascript
运行
复制
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密钥,用户可以访问它们。有人能告诉我问题出在哪里吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2020-03-24 08:09:44

git远程添加源ssh://username@github.com/foo/project.git

这不应该使用username,而应该使用git,如下所示:

代码语言:javascript
运行
复制
git remote add origin ssh://git@github.com/foo/project.git
票数 1
EN

Stack Overflow用户

发布于 2020-03-24 06:30:02

您似乎没有将SSH密钥添加到您的GitHub帐户中。看看这个文档如何做到这一点。

票数 0
EN

Stack Overflow用户

发布于 2020-03-24 07:56:28

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

您应该确保您的私钥名为id_rsa,或者您已经运行了ssh-agent并添加了该密钥。如果要运行ssh代理并添加密钥,请尝试以下操作:

代码语言:javascript
运行
复制
$ eval `ssh-agent`
$ ssh-add /path/to/private_key
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60825714

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档