简体   繁体   English

SSH - 服务器上的权限被拒绝(公钥)

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

I am trying to use git on my shared hosting on Hostgator but I am having issues establishing a connection with Github.我正在尝试在 Hostgator 上的共享主机上使用 git,但在与 Github 建立连接时遇到问题。 I already tried tons of answers online but nothing have changed so far.我已经在网上尝试了大量答案,但到目前为止没有任何改变。

These are the steps that I followed in order to achieve that (I used this github guide ):这些是我为实现这一目标而遵循的步骤(我使用了这个 github 指南):

On my machine,在我的机器上,

1. I made a new key with ssh-keygen -t ed25519 -C "myemail@address.com" 1.我用ssh-keygen -t ed25519 -C "myemail@address.com"了一个新密钥

2. I saved it into the file ~/.ssh/remote_github.pub , the file has no passphrase 2.我保存到文件~/.ssh/remote_github.pub ,文件没有密码

3. Then I ran eval "$(ssh-agent -s)" 3.然后我运行eval "$(ssh-agent -s)"

4. In my ~/.ssh/config file I specified 4.在我指定的~/.ssh/config文件中

Host *
  Hostname IP-ADDRESS-OF-SERVER
  AddKeysToAgent yes
  IdentityFile ~/.ssh/remote_github
  IdentitiesOnly yes

5. I copied the public key with pbcopy < ~/.ssh/remote_github.pub and saved it into my github account 5.我用pbcopy < ~/.ssh/remote_github.pub复制了pbcopy < ~/.ssh/remote_github.pub保存到我的github账户

6. Then I ran ssh-copy-id -i ~/.ssh/remote_github.pub myuser@remoteserver 6.然后我运行ssh-copy-id -i ~/.ssh/remote_github.pub myuser@remoteserver

And the answer was答案是

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:

After inserting the 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.

Checking the authorized_keys file on the server I see the same exact public key remote_github.pub stored in my machine*检查服务器上的authorized_keys文件,我看到存储在我的机器中的完全相同的公钥remote_github.pub *

7. But at this point, if I try to run ssh -T -v git@github.com 7.但此时,如果我尝试运行ssh -T -v git@github.com

This is what I get:这就是我得到的:

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).

I also made sure to change the permissions on the server with chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys but the answer is always Permission denied (publickey).我还确保使用chmod 700 ~/.sshchmod 600 ~/.ssh/authorized_keys更改服务器上的权限,但答案始终是Permission denied (publickey).

What am I doing wrong?我究竟做错了什么? Or missing?还是失踪了?

Thank you.谢谢你。

*the authorized_keys file contains also another ssh-rsa public key. * authorized_keys文件还包含另一个ssh-rsa公钥。

First, if your private key has no passphrase, you don't need anything related to ssh-agent.首先,如果你的私钥没有密码,你就不需要任何与 ssh-agent 相关的东西。

Second, "he authorized_keys file on the server I see the same exact public key remote_github.pub stored in my machine*" means you can connect to your server from your local machine.其次,“他在服务器上的authorized_keys 文件我看到存储在我的机器中的完全相同的公钥remote_github.pub*”意味着您可以从本地机器连接到您的服务器。
It has nothing to do with GitHub.它与 GitHub 无关。

If you want to connect to GitHub from the remote server, then you would need for that remote server account to have your private key.如果您想从远程服务器连接到 GitHub,那么您需要该远程服务器帐户拥有您的私钥。

If you want to connect to GitHub from your local machine, then Hostgator is not involved at all.如果你想从你的本地机器连接到 GitHub,那么 Hostgator 根本不涉及。

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

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