Estou tentando estabelecer uma comunicação SSH bidirecional entre um MacBook (192.168.1.3) executando o OS X 10.9.5 e um computador desktop (192.168.1.2) executando o Korora 23 (basicamente o Fedora 23 com aplicativos adicionais, pacotes, & repositórios na instalação). Eu configurei cada computador como um host e um cliente. Pode com êxito ssh do cliente OS X para o host Linux, mas indo do cliente Linux para o host OS X resulta nessa saída (eu substituí o número da porta por xxxxx):
$ ssh MacBook -vvv
OpenSSH_7.2p2, OpenSSL 1.0.2g-fips 1 Mar 2016
debug1: Reading configuration data /home/alex/.ssh/config
debug1: /home/alex/.ssh/config line 1: Applying options for *
debug1: /home/alex/.ssh/config line 4: Applying options for MacBook
debug3: kex names ok: [diffie-hellman-group-exchange-sha256]
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "192.168.1.3" port xxxxx
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.168.1.3 [192.168.1.3] port xxxxx.
debug1: Connection established.
debug1: identity file /home/alex/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/alex/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 192.168.1.3:xxxxx as 'alex'
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,ext-info-c
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256- ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128- cbc,aes192-cbc,aes256-cbc,arcfour
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256- ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour
debug2: MACs ctos: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
debug2: MACs stoc: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
debug2: compression ctos: [email protected],zlib,none
debug2: compression stoc: [email protected],zlib,none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-md5 compression: [email protected]
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-md5 compression: [email protected]
debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1543/3072
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:gv0L2YQKQKyddwo09OecUJcy/W5ACn/PxzmhBqh9i4I
debug3: put_host_port: [192.168.1.3]:xxxxx
debug3: put_host_port: [192.168.1.3]:xxxxx
debug3: hostkeys_foreach: reading file "/home/alex/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/alex/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [192.168.1.3]:xxxxx
debug3: hostkeys_foreach: reading file "/home/alex/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/alex/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [192.168.1.3]:xxxxx
debug1: Host '[192.168.1.3]:xxxxx' is known and matches the RSA host key.
debug1: Found key in /home/alex/.ssh/known_hosts:1
debug2: bits set: 1520/3072
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: /home/alex/.ssh/id_rsa (0x5605a87e8660), explicit
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey
debug3: authmethod_lookup publickey
debug3: remaining preferred:
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/alex/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
No host do OS X em /private/var/log/system.log
, a única entrada relevante parece ser:
MacBook.local sshd[2291]: Connection closed by 192.168.1.2 [preauth]
Propriedade & permissões no Linux:
$ ls -al /home
total 32
drwxr-xr-x. 4 alex alex 4096 Apr 7 15:49 .
dr-xr-xr-x. 18 root root 4096 Feb 6 13:59 ..
drwx------. 28 alex alex 4096 Apr 12 15:07 alex
drwx------. 2 root root 16384 Apr 7 15:41 lost+found
$ ls -al ~/.ssh/
total 32
drwx------. 2 alex alex 4096 Apr 11 16:40 .
drwx------. 28 alex alex 4096 Apr 12 15:07 ..
-rw-------. 1 alex alex 400 Apr 4 23:50 authorized_keys
-rw-------. 1 alex alex 2540 Apr 12 13:48 config
-rw-------. 1 alex alex 1679 Apr 11 16:28 id_rsa
-rw-r--r--. 1 alex alex 394 Apr 11 16:28 id_rsa.pub
-rw-------. 1 alex alex 401 Apr 11 16:40 known_hosts
No OS X:
ls -al ~/.ssh/
total 64
drwx------ 8 alex alex 272 11 Apr 16:43 .
drwxr-xr-x@ 73 alex staff 2482 12 Apr 15:13 ..
-rw-r--r--@ 1 alex alex 6148 11 Apr 16:43 .DS_Store
-rw-------@ 1 alex alex 719 11 Apr 16:39 authorized_keys.rtf
-rw-------@ 1 alex alex 2556 5 Apr 00:13 config
-rw------- 1 alex alex 1675 4 Apr 23:04 id_rsa
-rw-r--r-- 1 alex alex 400 4 Apr 23:04 id_rsa.pub
-rw------- 1 alex alex 401 8 Apr 22:31 known_hosts
Também tentou 644 permissões em authorized_keys
e known_hosts
em ambos os computadores. Ter reemitido pares de chaves do cliente Linux (onde o problema parece estar), mas nada mudou.
Eu colei manualmente as chaves públicas dos clientes nos arquivos authorized_keys
dos hosts, garantindo que a chave esteja em uma única linha; também colou-os no campo Chave de autenticação SSH do roteador.
Ter pesquisado e lido por horas; não encontrei muito que abordasse as seguintes linhas, que parecem ser a chave para o problema:
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
Minha situação de conexão fechada pelo cliente parece ser muito menos comum que a conexão fechada pelo host.
Agradeceria muito a ajuda.
Obrigado axiac por pegar o meu erro bobo. Além de ver a extensão .rtf e perceber que o formato estava errado, alguma outra saída forneceu pistas para resolver o problema?
Eu fui para Obter Informações para esse arquivo, removi o .rtf, abri com o iText Express, fui para o Style e marquei Plain, salvei em /.ssh, mudei de propriedade e permissões, removi o outro arquivo authorized_keys
, reiniciei o Mac e, finalmente, pode se conectar a partir do cliente Linux! Depois de todas as configurações de arquivos, firewalls, permissões - em dois sistemas operacionais diferentes, SELinux, roteador e talvez outras configurações que nem me lembro, tudo se resumiu a um erro de fonte estúpido para um arquivo. O SSH é um excelente protocolo para transferir arquivos entre dois computadores, mas definitivamente implacável e não é fácil de acertar. Especialmente ao trabalhar com diferentes sistemas operacionais e querer ir em ambas as direções. Obrigado novamente.