Não é possível usar chaves RSA com SSH: Servidor recusou nossa chave

1

Estou tentando usar chaves públicas / privadas RSA geradas pelo PuTTY para efetuar login em dois computadores GNU / Linux de computadores Windows, e ele funciona para um, mas não para o computador Ubuntu. As chaves foram geradas em um PC com Windows 7. Dele eu posso entrar em um Beaglebone Black executando a distro Angstrom. Copiei as chaves para um laptop com Windows 7 e obtive êxito também com o BBB, mas não com o computador com Ubuntu. Eu recebo a seguinte mensagem no terminal do PuTTY:

Using username "user".
Server refused our key
Using keyboard-interactive authentication.
Password:

Eu posso concluir o login digitando a senha, mas eu realmente quero que as chaves funcionem para que eu possa eliminar os logins de senha pela Internet. O nome de usuário é diferente entre os dois servidores, mas acho que não tem problema, né?

Estou usando o Ubuntu 14.04 LTS que possui o openssh-server instalado. Eu copiei a chave pública do PuTTYgen e a colei em ~ / .ssh / known_hosts. A chave está em apenas uma linha, começando assim: ssh-rsa AAAAB...

O diretório ~ / .ssh tem permissões definidas para 700, ~ / .ssh / known_hosts é definido como 600.

Eu tinha grandes esperanças quando encontrei este post neste fórum, mas nenhuma dessas soluções resolveu o problema.

Em um ponto, eu acidentalmente apaguei as chaves do host em / etc / ssh /, mas eu desinstalei o openssh-server e depois o reinstalei, o que trouxe de volta essas chaves. Bem, pelo menos parece que eu consegui tudo de volta.

Eu abri um terminal do PuTTY e emiti tail -f /var/log/auth.log , e tentei logar em um segundo terminal. Nada esclarecedor apareceu. A primeira mensagem reconheceu que o login da senha foi bem-sucedido, mas nada sobre as chaves.

Eu tenho mexido com o arquivo de configuração / etc / ssh / sshd_config tentando acertar a combinação certa de configurações, cada vez reiniciando o daemon com service ssh restart . Abaixo está esse arquivo como está agora. Acho que posso estar perdendo alguma coisa lá, mas estou ficando sem ideias.

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes no

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication yes

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
    
por spanky 01.02.2015 / 09:30

1 resposta

3

Como a steeldriver apontou, a chave RSA entra no arquivo authorized_keys , não known_hosts .

Eu cortei a chave do known_hosts , criei e colei no authorized_keys . chmod 600 authorized_keys , sudo service ssh restart e o servidor está funcionando.

Obrigado pela sua resposta steeldriver.

    
por spanky 01.02.2015 / 18:11