簡體   English   中英

SSH - 服務器上的權限被拒絕(公鑰)

[英]SSH - Permission denied (publickey) on server

我正在嘗試在 Hostgator 上的共享主機上使用 git,但在與 Github 建立連接時遇到問題。 我已經在網上嘗試了大量答案,但到目前為止沒有任何改變。

這些是我為實現這一目標而遵循的步驟(我使用了這個 github 指南):

在我的機器上,

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復制了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 ~/.sshchmod 600 ~/.ssh/authorized_keys更改服務器上的權限,但答案始終是Permission denied (publickey).

我究竟做錯了什么? 還是失蹤了?

謝謝你。

* authorized_keys文件還包含另一個ssh-rsa公鑰。

首先,如果你的私鑰沒有密碼,你就不需要任何與 ssh-agent 相關的東西。

其次,“他在服務器上的authorized_keys 文件我看到存儲在我的機器中的完全相同的公鑰remote_github.pub*”意味着您可以從本地機器連接到您的服務器。
它與 GitHub 無關。

如果您想從遠程服務器連接到 GitHub,那么您需要該遠程服務器帳戶擁有您的私鑰。

如果你想從你的本地機器連接到 GitHub,那么 Hostgator 根本不涉及。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM