首页 > 解决方案 > Hetzner 错误:权限被拒绝(公钥)

问题描述

我正在尝试通过 hetzner deploy 上的 rails gemfile 从 github 获取 repo!但是在 ssh 中显示了这个结果!

ssh -vT git@github.com
OpenSSH_7.6p1 Ubuntu-4ubuntu0.5, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/dc/.ssh/config
debug1: /home/dc/.ssh/config line 1: Applying options for github.com
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.121.3] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/dc~/.ssh/id_rsa.pub type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dc~/.ssh/id_rsa.pub-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.5
debug1: Remote protocol version 2.0, remote software version babeld-322814ef
debug1: no match: babeld-322814ef
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:XXXXXxxxxxXXXXXXXXXXXX
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/dc/.ssh/known_hosts:16
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-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).

我已经尝试了一切,因为在 /etc/ssh/sshd_config 上更改 PasswordAuthentication yes

在 known_hosts 和 authorized_keys 添加了 keygen 在 server 和 github 上添加了 keygen

创建一个ed25519 keygen并尝试过

一切仍然

github 给我 git@github.com:权限被拒绝

.ssh/config 文件

Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
Port 22
IdentityFile /home/dc~/.ssh/id_rsa.pub

标签: githubsshclouddigital-oceanvps

解决方案


hetzner 专用服务器上,您首先需要检查的是:

ssh -Tv git@github.com

只要您没有看到“欢迎”消息,任何其他进程(假设它是使用该服务器上的相同用户帐户执行的)将无法使用 SSH 从 GitHub 获取。


推荐阅读