linux - SSH 连接到远程服务器上的 GitHub

标签 linux github ssh server

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

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

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

在远程服务器上检查,我的公钥在 authorized_keys 中。 我的公钥也在我的 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).

最佳答案

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

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

关于linux - SSH 连接到远程服务器上的 GitHub,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65337343/

相关文章:

r - 数据未从 R 中的命名空间导出

git - 仍然比较 Squash merge 后的 promise 差异

linux - 一个衬垫,用于使用 xargs 在其他命令生成的搜索文本上 grep 一个命令的输出

android - Windows- 无法启动 Git : Probably the path to Git executable is not valid

c++ - 可以从用户空间找到 mmap 页面的脏污度吗?

linux - Makefile:3: *** 缺少分隔符。停止

emacs - "yank"通过 SSH 使用 Emacs 时不粘贴文本

通过 ssh 在远程服务器上运行多个不相关命令的 Java 库

python - 按行将文件拆分成许多不同的文件 - 用原始文件的索引命名每个文件

java - (Java) "error: cannot find symbol"编译时?