O arquivo de configuração global /etc/ssh_config
tinha a seguinte diretiva:
BatchMode yes
Isso suprime o desafio da senha. Comentar essa linha resolveu o problema.
Estou executando um servidor / cliente ssh Ubuntu 12.04 para enviar arquivos para fornecedores com os quais trabalhamos. Recentemente, tentei adicionar um novo fornecedor enviando meu arquivo id_rsa.pub
, mas não consegui me conectar. Eu tenho testado isso localmente e descobri que meu cliente ssh não se conectará a nenhum novo servidor. O cliente ssh nunca apresenta a pergunta padrão, ou seja,
The authenticity of host x.x.x.x......... Are you sure you want to continue connecting (yes/no).
Eu tentei conectar a três servidores locais, todos com o mesmo resultado negativo. Todos os outros clientes podem se conectar a esses mesmos três servidores.
Não consigo me conectar a esses servidores, a menos que eu exporte meu id_rsa.pub
para seus authorized_keys
Se eu colocar minha chave pública nesses servidores, ela ainda falhará com
Host key verification failed
nunca pedindo uma frase secreta. Meu trabalho é ssh -o StrictHostKeyChecking=no user@server
. Somente depois de exportar meu id_rsa.pub
para o controle remoto authorized_keys
.
A questão é por que nunca me pedem para adicionar uma nova chave a 'known_hosts' e por que devo exportar a chave pública para conectar?
known_hosts
com ssh-keygen -R x.x.x.x
. known_hosts
. ran eval "$(ssh-agent)", ssh-add -D, and ssh-add
. known_hosts
permissões, tentei 600 e 644. Obrigado
netmgr@FTP-Inside:~/.ssh$ ssh -vvv [email protected]
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 10.20.11.11 [10.20.11.11] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/netmgr/.ssh/id_rsa" as a RSA1 public key
debug1: identity file /home/netmgr/.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/netmgr/.ssh/id_rsa-cert type -1
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/netmgr/.ssh/id_dsa" as a RSA1 public key
debug1: identity file /home/netmgr/.ssh/id_dsa type 2
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
debug1: identity file /home/netmgr/.ssh/id_dsa-cert type -1
debug1: identity file /home/netmgr/.ssh/id_ecdsa type -1
debug1: identity file /home/netmgr/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "10.20.11.11" from file "/home/netmgr/.ssh/known_hosts"
debug3: load_hostkeys: loaded 0 keys
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
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
debug2: dh_gen_key: priv key bits set: 110/256
debug2: bits set: 496/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA a3:03:06:34:55:04:b8:71:8f:b7:65:cc:43:a5:58:43
debug3: load_hostkeys: loading entries for host "10.20.11.11" from file "/home/netmgr/.ssh/known_hosts"
debug3: load_hostkeys: loaded 0 keys
Host key verification failed.
O arquivo de configuração global /etc/ssh_config
tinha a seguinte diretiva:
BatchMode yes
Isso suprime o desafio da senha. Comentar essa linha resolveu o problema.
Verifique se o servidor permite a autenticação de senha. Para compartilhar sua chave, você precisará efetuar o logon uma vez e, para isso, precisará de autenticação de senha, a menos que sua chave seja adicionada manualmente ao arquivo authorized_keys
remoto no servidor como você fez.
No final do servidor, edite /etc/ssh/sshd_config
para ter:
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes
Reinicie o servidor ssh com sudo service ssh restart
no servidor.
Agora envie sua chave para o servidor com ssh-copy-id username@remotehost
Quando a chave está no servidor remoto, você pode desabilitar a autenticação de senha em /etc/ssh/sshd_config
da mesma forma que a habilitou, lembrando-se de reiniciar novamente o ssh no servidor.