【问题标题】:SSH Connection to GitHub on a remote serverSSH 连接到远程服务器上的 GitHub
【发布时间】:2021-03-27 22:40:57
【问题描述】:

我正在尝试在我的远程服务器 Debian 上使用 SSH 克隆我的 repo GitHub。

在本地,我有键 id_ed25519.pubid_ed25519。 我做了一个

sh-copy-id -i ~/.ssh/id_ed25519.pub user@host

在远程服务器上检查,我的 pubkey 在 authorized_keys 内。 我的 pubkey 也在我的 GitHub 帐户上。

在我的远程服务器上,我的 sshd_config 有:

AuthorizedKeysFile      ~/.ssh/authorized_keys

PubkeyAuthentication yes

PasswordAuthentication no

执行 ssh -vT git@github.com 时:

OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [...] port 22.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2
debug1: Remote protocol version 2.0, remote software version babeld-78794f53
debug1: no match: babeld-78794f53
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: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:.......
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: Will attempt key: /root/.ssh/id_rsa
debug1: Will attempt key: /root/.ssh/id_dsa
debug1: Will attempt key: /root/.ssh/id_ecdsa
debug1: Will attempt key: /root/.ssh/id_ed25519
debug1: Will attempt key: /root/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
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: Trying private key: /root/.ssh/id_xmss
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).

【问题讨论】:

    标签: linux github ssh server


    【解决方案1】:

    您的远程服务器不知道您的私钥。
    通常您不想将私钥复制到远程服务器。

    但是在从本地机器连接到远程服务器时,您可以使用代理转发 ssh myuser@remoteserver -A
    这允许远程服务器使用您的私钥,但无法访问密钥本身。
    或者您可以将ForwardAgent yes 添加到您的~/.ssh/config 文件中

    【讨论】:

      猜你喜欢
      • 2020-06-17
      • 2018-12-04
      • 1970-01-01
      • 1970-01-01
      • 2016-02-13
      • 2013-08-09
      • 2017-08-01
      • 2023-03-08
      • 1970-01-01
      相关资源
      最近更新 更多