Não é possível configurar o login do ssh sem digitar a senha

7

Eu configurei automaticamente o login ssh sem digitar a senha para um servidor:

cd ~/.ssh

ssh-keygen

ssh-copy-id -i ~/.ssh/id_rsa.pub tim@server1

Funciona no servidor.

Mais tarde fiz o mesmo em um servidor diferente.

ssh-copy-id -i ~/.ssh/id_rsa.pub tim@server2

Imediatamente eu ssh tim@server2 , mas ainda requer minha senha. Eu fiz algo incorretamente? Quais são alguns possíveis motivos que não foram configurados com êxito no segundo servidor? (note que o segundo servidor executa o sistema de arquivos kerberos e Andrew)

$ ssh -v tim@server2
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to server2 [...] port 22.
debug1: Connection established.
debug1: identity file /home/tim/.ssh/id_rsa type 1
debug1: identity file /home/tim/.ssh/id_rsa-cert type -1
debug1: identity file /home/tim/.ssh/id_dsa type -1
debug1: identity file /home/tim/.ssh/id_dsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ecdsa type -1
debug1: identity file /home/tim/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ed25519 type -1
debug1: identity file /home/tim/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
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<3072<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 'server2' is known and matches the RSA host key.
debug1: Found key in /home/tim/.ssh/known_hosts:70
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,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/tim/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Trying private key: /home/tim/.ssh/id_dsa
debug1: Trying private key: /home/tim/.ssh/id_ecdsa
debug1: Trying private key: /home/tim/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Password:

Eu tentei o método do Anthon de usar as chaves Diffie-Hellman, mas ele ainda me pede a senha.

$ cd ~/.ssh
$ ssh-keygen -t dsa
$ ssh-copy-id -i ~/.ssh/id_dsa.pub tim@server2
$ ssh -v tim@server2
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to server2 [...] port 22.
debug1: Connection established.
debug1: identity file /home/tim/.ssh/id_rsa type 1
debug1: identity file /home/tim/.ssh/id_rsa-cert type -1
debug1: identity file /home/tim/.ssh/id_dsa type 2
debug1: identity file /home/tim/.ssh/id_dsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ecdsa type -1
debug1: identity file /home/tim/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/tim/.ssh/id_ed25519 type -1
debug1: identity file /home/tim/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
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<3072<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 ...
debug1: Host 'server2' is known and matches the RSA host key.
debug1: Found key in /home/tim/.ssh/known_hosts:70
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,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Next authentication method: publickey
debug1: Offering DSA public key: /home/tim/.ssh/id_dsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Offering RSA public key: /home/tim/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Trying private key: /home/tim/.ssh/id_ecdsa
debug1: Trying private key: /home/tim/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Password:
    
por Tim 30.06.2015 / 14:27

3 respostas

8

Você menciona que o segundo servidor está usando o Andrew File System (AFS).

Eu não trabalhei com isso, mas pelo que entendi, o AFS é um sistema de arquivos protegido por Kerberos que requer um ticket do kerberos para funcionar. Isso significa que você precisa estar conectado ao território Kerberos do seu site para poder acessar seu diretório pessoal.

Se você fizer logon com a senha, server2 provavelmente será configurado para que você efetue o logon em seu território do Kerberos por meio do PAM. Se você estiver usando chaves SSH, no entanto, server2 não obterá as informações necessárias para fazer isso e você não poderá acessar seu diretório pessoal.

Felizmente, na saída ssh -v da sua pergunta, podemos inferir que seu servidor tem GSSAPI autenticação ativada. Isso deve permitir que você execute um logon sem senha, desde que você tenha um ticket kerberos válido para o seu território. Faça o seguinte:

  • Faça logon no server2 e execute o programa klist . Isso retornará algo nas seguintes linhas:

    Ticket cache: FILE:/tmp/krb5cc_2000
    Default principal: [email protected]
    
    Valid starting     Expires            Service principal
    28-05-15 15:01:31  29-05-15 01:01:31  krbtgt/[email protected]
        renew until 29-05-15 15:01:28
    28-05-15 15:02:04  29-05-15 01:01:31  IMAP/[email protected]
        renew until 29-05-15 15:01:28
    

    procure a linha que começa com Default principal: . Ele diz qual é o seu kerberos principal (no exemplo acima, é [email protected] ). Anote isso. Observe que não é um endereço de e-mail e é sensível a maiúsculas e minúsculas; ou seja, o principal termina com EXAMPLE.ORG , não example.org .

  • Na máquina do cliente, execute kinit com o nome do seu principal (ou seja, no exemplo acima, isso seria kinit [email protected] ). Se tudo correr bem, quando você executar klist novamente, verá que tem um cache de tickets em sua máquina local.
  • Se você executar agora ssh -K server2 , poderá fazer o login e o sistema não deverá solicitar uma senha.

Por favor, note que devido ao funcionamento do Kerberos, um cache de ticket tem validade limitada. Não é possível solicitar um cache de ticket com validade maior do que o configurado pelo administrador da região (que geralmente é de aproximadamente 10 horas). Quando o seu bilhete expirar, você precisará executar kinit novamente e digitar sua senha mais uma vez.

    
por 30.06.2015 / 16:15
5

Você deve tentar se conectar ao server2 com:

ssh -v tim@server2

e compare isso com o mesmo, conectando-se a server1 , isso dirá exatamente onde os dois servidores são diferentes.

O mais provável é que haja uma diferença em /etc/ssh/sshd_config nas duas máquinas. onde server2 ou seu ~/.ssh tem problemas de acessibilidade (não restritos o suficiente).

A partir da saída -v , você pode ver que oferece uma chave privada RSA para verificar (em /home/tim/.ssh/id_rsa ), mas parece que server2 suporta apenas Diffie-Hellman (e tenta /home/tim/.ssh/id_dsa , que é provavelmente nem mesmo lá).

    
por 30.06.2015 / 14:37
4

Adicione a seguinte entrada na máquina cliente a partir da qual você está tentando ssh.

arquivo de configuração: /etc/ssh/ssh_config

GSSAPIAuthentication no

Depois disso, você será capaz de usar o ssh na máquina.

Se você não tiver permissões de edição para esse arquivo, também poderá adicionar

Host *
  GSSAPIAuthentication no

para ~/.ssh/config (crie este arquivo se ele não existir)

    
por 05.01.2017 / 06:24

Tags