SSH - 服务器上的权限被拒绝(公钥)
SSH - Permission denied (publickey) on server
我正尝试在 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
复制了 public 密钥并将其保存到我的 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
文件,我看到完全相同的 public 密钥 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
public 密钥。
首先,如果您的私钥没有密码,您不需要任何与 ssh-agent 相关的东西。
其次,“他在服务器上的 authorized_keys 文件我看到完全相同的 public 密钥 remote_github.pub 存储在我的机器中*”意味着您可以从本地连接到您的服务器机.
与GitHub.
无关
如果您想从远程服务器连接到 GitHub,那么您需要该远程服务器帐户拥有您的私钥。
如果您想从本地计算机连接到 GitHub,则根本不涉及 Hostgator。
我正尝试在 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
复制了 public 密钥并将其保存到我的 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
文件,我看到完全相同的 public 密钥 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
public 密钥。
首先,如果您的私钥没有密码,您不需要任何与 ssh-agent 相关的东西。
其次,“他在服务器上的 authorized_keys 文件我看到完全相同的 public 密钥 remote_github.pub 存储在我的机器中*”意味着您可以从本地连接到您的服务器机.
与GitHub.
如果您想从远程服务器连接到 GitHub,那么您需要该远程服务器帐户拥有您的私钥。
如果您想从本地计算机连接到 GitHub,则根本不涉及 Hostgator。