O servidor não aceita chave pública para login ssh sem senha [duplicado]

24

Eu tenho acesso ssh a dois sever. Um antigo e um novo. Para o antigo eu uso o login SSH sem senha do tutorial para fazer o login sem digitar a senha todas as vezes.

Para a nova máquina eu segui o tutorial novamente, mas desta vez não está funcionando. Eu olhei para a saída de depuração de ssh ( -v opção) e parece-me que o novo servidor não accept minha chave pública. Mas eu verifiquei e bot authorized_keys são os mesmos, eu até usei md5sum .

Qual poderia ser o problema e como eu poderia consertar isso?

Depuração do servidor antigo onde ele funciona (snippet):

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/NICK/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277

Saída de depuração para o novo servidor em que ele não funciona (snippet):

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/NICK/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/NICK/.ssh/id_dsa

[ UPDATE] Propriedade de authorized_keys no controle remoto

NICK@server-new:~/.ssh$ ls -l
total 4
-rwx------ 1 NICK NICK 404 2012-08-08 16:11 authorized_keys

Conclua a saída de depuração para o servidor que não está funcionando:

OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /home/NICK/.ssh/config
debug1: /home/NICK/.ssh/config line 1: Applying options for foo2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to foo-serv2.cs.bar.it [XXX.XXX.XXX.XXX] port 22.
debug1: Connection established.
debug1: identity file /home/NICK/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/NICK/.ssh/id_rsa-cert type -1
debug1: identity file /home/NICK/.ssh/id_dsa type -1
debug1: identity file /home/NICK/.ssh/id_dsa-cert type -1
debug1: identity file /home/NICK/.ssh/id_ecdsa type -1
debug1: identity file /home/NICK/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-4ubuntu6
debug1: match: OpenSSH_5.5p1 Debian-4ubuntu6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr 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: Server host key: RSA XXX
debug1: Host 'foo-serv2.cs.bar.it' is known and matches the RSA host key.
debug1: Found key in /home/NICK/.ssh/known_hosts:34
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,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/NICK/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/NICK/.ssh/id_dsa
debug1: Trying private key: /home/NICK/.ssh/id_ecdsa
debug1: Next authentication method: password
    
por Framester 08.08.2012 / 16:08

2 respostas

30

Você se certificou de que a propriedade e o modo do seu diretório ~ / .ssh no lado remoto estão corretos? Ele deve pertencer a você e ter 0700 permissões, ou seja, chmod 700 ~/.ssh . Também chmod go-w ~ , como isso é verificado também - porque qualquer pessoa com permissão de gravação em seu diretório home pode alterar as permissões do diretório .ssh.

    
por 08.08.2012 / 18:34
6

Compare os arquivos de configuração sshd (os meus em /etc/ssh/sshd_config ) no servidor antigo e no novo - algo é configurado de maneira diferente no novo, por exemplo, a opção AuthorizedKeysFile no novo aponta para algum outro arquivo ( Acredito que algumas instalações SSH atualmente chamam o arquivo authorized_keys2 )?

    
por 08.08.2012 / 17:38

Tags