Eu gosto de trabalhar ocasionalmente com alguns repositórios do Github do meu computador de trabalho (Windows 7). Depois de passar muito mais tempo do que eu esperava para aprender como funciona o SSH, criei um conjunto diferente de chaves registradas na minha conta pessoal e um host personalizado no meu arquivo .ssh/config
para usá-los com o github. Parece assim:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github_rsa
IdentitiesOnly yes
Host github-personal
HostName github.com
User git
IdentityFile ~/.ssh/{personal-username}_github_rsa
IdentitiesOnly yes
Host *
IdentitiesOnly yes
Há algum tempo, eu consegui criar um repositório pessoal no meu computador de trabalho com os controles remotos parecendo
git@github-personal:{personal-username}/{repo}
que funcionou bem. Recentemente, porém, tentei configurar outro e parece que ele continua tentando oferecer meu arquivo de identidade ~/ssh/github_rsa
. Correndo ssh -v git@github-personal
eu recebo:
debug1: Reading configuration data /c/Users/Admin/.ssh/config
debug1: /c/Users/Admin/.ssh/config line 7: Applying options for github-personal
debug1: /c/Users/Admin/.ssh/config line 13: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 1: Applying options for *
debug1: Hostname has changed; re-reading configuration
debug1: Reading configuration data /c/Users/Admin/.ssh/config
debug1: /c/Users/Admin/.ssh/config line 1: Applying options for github.com
debug1: /c/Users/Admin/.ssh/config line 13: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 1: Applying options for *
debug1: /etc/ssh/ssh_config line 5: Applying options for github.com
debug1: Connecting to github.com [192.30.252.129] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Admin/.ssh/{personal-username}_github_rsa type 1
debug1: identity file /c/Users/Admin/.ssh/{personal-username}_github_rsa-cert type -1
debug1: identity file /c/Users/Admin/.ssh/github_rsa type 1
debug1: identity file /c/Users/Admin/.ssh/github_rsa-cert type -1
debug1: identity file /c/Users/Admin/.ssh/github_rsa type 1
debug1: identity file /c/Users/Admin/.ssh/github_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
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: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/Admin/.ssh/github_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([192.30.252.129]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
PTY allocation request failed on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi {work-username}! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Connection to github.com closed.
Transferred: sent 3568, received 1800 bytes, in 0.2 seconds
Bytes per second: sent 20744.2, received 10465.1
debug1: Exit status 1
Olhando para estas duas linhas:
debug1: Offering RSA public key: /c/Users/Admin/.ssh/github_rsa
...
Hi {work-username}! You've successfully authenticated, but GitHub does not provide shell access.
está oferecendo claramente minha chave de trabalho padrão. Parece-me que o problema está em algum lugar por aqui:
debug1: /c/Users/Admin/.ssh/config line 7: Applying options for github-personal
...
debug1: Hostname has changed; re-reading configuration
...
debug1: /c/Users/Admin/.ssh/config line 1: Applying options for github.com
Onde inicialmente lê a configuração correta do host, mas muda de idéia e lê o host padrão do github. Lembro-me de ter um problema semelhante da última vez e adicionar IdentitiesOnly yes
foi a resposta, mas eu já tenho isso.