【发布时间】:2021-03-04 23:40:12
【问题描述】:
我正在尝试在 Hostgator 上的共享主机上使用 git,但在与 Github 建立连接时遇到问题。我已经在网上尝试了很多答案,但到目前为止没有任何改变。
这些是我为了实现这一目标而遵循的步骤(我使用了this github guide):
在我的机器上,
1.我用ssh-keygen -t ed25519 -C "myemail@address.com"创建了一个新密钥
2.我保存到文件~/.ssh/remote_github.pub,文件没有
密码
3. 然后我跑了eval "$(ssh-agent -s)"
4.在我指定的~/.ssh/config 文件中
Host *
Hostname IP-ADDRESS-OF-SERVER
AddKeysToAgent yes
IdentityFile ~/.ssh/remote_github
IdentitiesOnly yes
5.我用pbcopy < ~/.ssh/remote_github.pub复制了公钥并将其保存到我的github帐户中
6. 然后我跑了ssh-copy-id -i ~/.ssh/remote_github.pub myuser@remoteserver
答案是
INFO: Source of key(s) to be installed: "/Users/mattiabombelli/.ssh/remote_github.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
mbombelli@192.254.233.200's password:
输入密码后:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'myuser@remoteserver'"
and check to make sure that only the key(s) you wanted were added.
检查服务器上的authorized_keys 文件,我看到存储在我的机器中的完全相同的公钥remote_github.pub*
7. 但此时,如果我尝试运行ssh -T -v git@github.com
这是我得到的:
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Connecting to github.com [140.82.113.3] port 22.
debug1: Connection established.
debug1: identity file /home1/mbombelli/.ssh/identity type -1
debug1: identity file /home1/mbombelli/.ssh/identity-cert type -1
debug1: identity file /home1/mbombelli/.ssh/id_rsa type -1
debug1: identity file /home1/mbombelli/.ssh/id_rsa-cert type -1
debug1: identity file /home1/mbombelli/.ssh/id_dsa type -1
debug1: identity file /home1/mbombelli/.ssh/id_dsa-cert type -1
debug1: identity file /home1/mbombelli/.ssh/id_ecdsa type -1
debug1: identity file /home1/mbombelli/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version babeld-c863b32e
debug1: no match: babeld-c863b32e
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home1/mbombelli/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home1/mbombelli/.ssh/identity
debug1: Trying private key: /home1/mbombelli/.ssh/id_rsa
debug1: Trying private key: /home1/mbombelli/.ssh/id_dsa
debug1: Trying private key: /home1/mbombelli/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey).
我还确保使用chmod 700 ~/.ssh 和chmod 600 ~/.ssh/authorized_keys 更改服务器上的权限,但答案始终是Permission denied (publickey).
我做错了什么?还是不见了?
谢谢。
*authorized_keys 文件还包含另一个 ssh-rsa 公钥。
【问题讨论】:
标签: git github ssh ssh-keys public-key