OpenSSH提供错误的公钥?
我尝试配置SSH以使用两个遥控器,每个遥控器都有不同的密钥对。因此,我创建了这个config
。OpenSSH提供错误的公钥?
UserKnownHostsFile ~/.ssh/known_hosts
Host github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_rsa
Host git.cloudhost.io
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/cloudhost
与Github的连接正常工作。
> ssh -T github.com
Hi danijar! You've successfully authenticated, but GitHub does not provide shell
access.
但是对于Cloudhost,连接失败。
> ssh -T git.cloudhost.io
Permission denied (publickey,password).
这里是Cloudhost的调试输出。
> ssh -v git.cloudhost.io
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Users/Name/.ssh/config
debug1: Applying options for git.cloudhost.io
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to git.cloudhost.io [31.220.27.160] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Name/.ssh/cloudhost type 1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.1p1 Debian-4
debug1: match: OpenSSH_6.1p1 Debian-4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<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 'git.cloudhost.io' is known and matches the RSA host key.
debug1: Found key in /c/Users/Name/.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,password
debug1: Next authentication method: publickey
debug1: Offering public key: C:\\Users\\Name\\.ssh\\github_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: C:\\Users\\Name\\.ssh\\github_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /c/Users/Name/.ssh/cloudhost
debug1: Authentications that can continue: publickey,password
debug1: No more authentication methods to try.
Permission denied (publickey,password).
线Offering public key: /c/Users/Name/.ssh/cloudhost
混淆了我,因为cloudhost
是私钥。公钥被命名为cloudhost.pub
。
如何通过ssh连接我的登录用户到Cloudhost?
从你的日志:
debug1: Reading configuration data /c/Users/Name/.ssh/config
debug1: Applying options for git.cloudhost.io
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
这是正确的配置文件?请仔细检查两个文件的内容。
也看看这个:
debug1: Offering public key: C:\\Users\\Name\\.ssh\\github_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
好像它提供了你的github上的关键,它的存在和甚至被服务器接受。
您确定该文件不存在吗?你确定你正在与正确的服务器通话吗?你确定你在服务器上正确配置了公钥吗?
感谢您的回复。配置文件是'C:/ Users/Name/.ssh/config'。我在哪里可以找到Windows上的第二个配置路径?对于第二件事,你是对的,在运行该命令后,一个'github_rsa'密钥对自动出现在'.ssh'目录中。也许这与我使用Github for Windows客户端附带的Git版本有关。我仍然不明白为什么Cloudhost服务器接受'github_rsa'键。当密钥与任何用户不匹配时,它可以通过回退到公共访问来接受每个密钥。 – danijar
'当密钥与任何用户不匹配时,它可能只是通过回退到公共访问来接受每个密钥,调试日志清楚地表明,在尝试Cloudhost密钥后,它回退到被接受的github密钥。 – AD7six
@ AD7six在删除所有本地存储库并通过SSH从远程再次克隆它们之后,它终于起作用了。我甚至可以从Github for Windows客户端提交提交。 – danijar
@ AD7six我重新安装了Github for Windows,因此Git。现在连接到'git.cloudhost.io'失败,并显示'Permission denied(publickey,password)'。问题已更新。 – danijar
输出表示提供并拒绝了“/ c/Users/Name/.ssh/cloudhost”。特别是根据公开/私人提及,听起来您的公钥不在远程位置,因此与云端主机密钥的连接失败。 – AD7six
@ AD7six我再次检查公钥是否添加到远程。当我在[本答案](http://*.com/a/8755199/1079110)中显示之前运行'git config --global http.sslVerify false'时,我可以克隆,推送和拉动我的私人存储库Cloudhost远程。 – danijar