简体   繁体   English

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

[英]SSH Connection to GitHub on a remote server

I'm trying to clone on of my repo GitHub with SSH on my remote server Debian.我正在尝试在我的远程服务器 Debian 上使用 SSH 克隆我的仓库 GitHub。

In local i have keys id_ed25519.pub and id_ed25519 .在本地我有键id_ed25519.pubid_ed25519 I have done an我做了一个

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

Checked on remote server and my pubkey is inside authorized_keys .检查远程服务器,我的 pubkey 在authorized_keys内。 My pubkey is on my GitHub account too.我的公钥也在我的 GitHub 帐户上。

On my remote server my sshd_config has:在我的远程服务器上,我的 sshd_config 有:

AuthorizedKeysFile      ~/.ssh/authorized_keys

and

PubkeyAuthentication yes

and

PasswordAuthentication no

When doing an ssh -vT git@github.com:在执行 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).

Your remote server doesn't know your private key.您的远程服务器不知道您的私钥。
Normally you don't want to copy the private key to a remote server.通常,您不想将私钥复制到远程服务器。

But while connecting from your local machine to the remote server, you can use the agent forwarding with ssh myuser@remoteserver -A但是从本地计算机连接到远程服务器时,您可以使用代理转发ssh myuser@remoteserver -A
This allows the remote server to use your private key, but without access to the key itself.这允许远程服务器使用您的私钥,但无法访问密钥本身。
Or you can add ForwardAgent yes into your ~/.ssh/config file或者您可以将ForwardAgent yes添加到您的~/.ssh/config文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM