[email protected]: 权限被拒绝(公钥)

[email protected]: 权限被拒绝(公钥)

我无法使用 SSH 从 github 克隆任何 repo。以下是控制台输出:

root@local-machine ~#  git clone [email protected]:getify/You-Dont-Know-JS.git js
Cloning into 'js'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

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


root@local-machine ~#  ll ~/.ssh/
total 24
drwx------  2 root root 4096 Apr 23 12:55 ./
drwx------ 14 root root 4096 Apr 23 15:39 ../
-rw-r--r--  1 root root  738 Mar 29 15:51 authorized_keys
-rw-------  1 root root 1679 Apr 23 12:55 id_rsa
-rw-r--r--  1 root root  403 Apr 23 12:55 id_rsa.pub
-rw-r--r--  1 root root  799 Apr 23 12:55 known_hosts


root@local-machine ~#  ssh -vT [email protected]
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [140.82.118.3] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version babeld-873429c4
debug1: no match: babeld-873429c4
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: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] 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 /root/.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 public key: RSA SHA256:WMXsJVQ6YFFr6165OpgEvekJFRGzW0eUAzUq2proYI0 /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

我做错了什么?谢谢

答案1

我做错了什么?

  1. 除非你有充分的理由,否则你的第一个错误可能是在本地机器上以 root 身份而不是普通用户身份登录签出 github repo。
  2. 您是否已在 github GUI 上为您的帐户声明了 rsa 公钥(单击您的图片 > 设置 > SSH 和 GPG 密钥)?您尝试的 repo 是公开的,因此除了 github 知道它之外,没有其他要求可以通过 ssh 克隆它。
  3. 如果您已经声明了密钥,您确定您没有使用个人帐户公共 RSA 密钥,而是使用了 root 使用的密钥(这又回到了第 1 点)吗?

相关内容