Pergunta

I try to configure ssh to use two remotes which each a different key pair. Therefore, I created this config.

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

The connection to Github works fine.

> ssh -T github.com
Hi danijar! You've successfully authenticated, but GitHub does not provide shell
access.

But for Cloudhost, the connection fails.

> ssh -T git.cloudhost.io
Permission denied (publickey,password).

Here is the debug output for 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).

The line Offering public key: /c/Users/Name/.ssh/cloudhost confuses me, because cloudhost is the private key. The public key is named cloudhost.pub.

How can I connect as my login user via ssh to Cloudhost?

Foi útil?

Solução

From your log:

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 *

Is this the correct config file? Please double check the content of both files.

Also look at this:

debug1: Offering public key: C:\\Users\\Name\\.ssh\\github_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).

Seems like it offered your github key, it existed and was even accepted by the server.

Are you sure that file does not exist? Are you sure you are talking to the right server? Are you sure you configured your public key correctly on the server?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top