ssh acesso com autenticação de chave não funciona

0

Estou tentando configurar uma conexão sem senha para jogar dois servidores, o primeiro (A) executa o servidor Win com o Cygwin e o segundo executa o Debian Linux. Eu segui este guia: link , então:

1. servidor de BD

1.a. chaves criadas:

ssh-keygen -t rsa -b 2048 -f /home/deb-user/cron/deb-rsync-key 

1.b copiado deb-rsync-key.pub no servidor Win usando scp & autenticação

2.Win servidor

2.um entrou no servidor Win usando ssh e autenticação e moveu deb-rsync-key.pub na pasta .ssh e então copiou o conteúdo no arquivo authorized_keys , que eu criei

2.b certificou-se de que a pasta .ssh tinha 700 permission e authorized_keys file 600 .

2.c certificou-se de que as chaves RSAAuthentication e PubkeyAuthentication em /etc/sshd/sshd_config não tinham comentários e yes

2.d Tentou definir o AuthorizedKeysFile como caminho absoluto apontando para o arquivo autorized_keys na pasta base do usuário (alterado de .ssh/autorized_keys para /home/win-user/.ssh/autorized_keys )

2.e reinicializou o servidor sshd ( net stop sshd , net start sshd )

servidor 3.Deb

Tentando acessar o servidor vencedor usando a chave:

ssh -i /home/deb-user/cron/deb-rsync-key win-user@win-host

tudo que eu obtenho é

Connection closed by win-host

Nada está registrado no DEB: /var/logs/auth.log

Nada está registrado no WIN: /var/logs/sshd.log

Qualquer ajuda será muito apreciada!

ATUALIZAÇÃO: Adicionando -v opção no comando ssh retorna isso:

OpenSSH_5.5p1 Debian-6+squeeze3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to win-host [win-host] port 22.
debug1: Connection established.
debug1: identity file /home/deb-user/cron/deb-rsync-key.pub 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/deb-user/cron/deb-rsync-key.pub-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0
debug1: match: OpenSSH_6.0 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze3
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: Host 'win-host' is known and matches the RSA host key.
debug1: Found key in /home/deb-host/.ssh/known_hosts:2
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,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /home/deb-host/cron/deb-rsync-key.pub
Connection closed by win-host

UPDATE2 as permissões de pasta do servidor wins .ssh são as seguintes:

$ ls -la .ssh
total 6
drwx------+ 1 win-user Domain Users   0 Mar 12 10:26 .
drwxr-xr-x+ 1 win-user Domain Users   0 Mar 12 10:25 ..
-rw-------  1 win-user Domain Users 396 Mar 12 10:26 authorized_keys
-rw-------  1 win-user Domain Users 396 Mar 12 10:24 deb-rsync-key.pub

UPDATE3: as permissões de pasta no servidor DEB são as seguintes:

$ ls -la /home/
total 16
drwxr-xr-x  4 root  root  4096 31 gen 11.19 .
drwxr-xr-x 22 root  root  4096 28 gen 11.59 ..
drwx------ 18 deb-user deb-user 4096 12 mar 11.15 deb-user

E permissões de pasta no servidor do Win da seguinte forma:

$ ls -la /home/
total 8
drwxrwxrwt+ 1 jbogdani root         0 Oct 20  2011 .
drwxr-xr-x+ 1 jbogdani root         0 Nov  1 00:44 ..
drwx------+ 1 win-user Domain Users 0 Mar 12 10:25 win-user

UPDATE4 Mais verboso:

$ ssh -vvv -i /home/de-user/cron/deb-rsync-key win-user@win-host
OpenSSH_5.5p1 Debian-6+squeeze3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to win-host [win-host] port 22.
debug1: Connection established.
debug3: Not a RSA1 key file /home/deb-user/cron/deb-rsync-key.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /home/deb-user/cron/deb-rsync-key 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/deb-user/cron/deb-rsync-key-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0
debug1: match: OpenSSH_6.0 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze3
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: 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],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-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],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: 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: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256
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]
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: 139/256
debug2: bits set: 528/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: host win-host filename /home/deb-user/.ssh/known_hosts
debug3: check_host_in_hostfile: host win-host filename /home/deb-user/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 2
debug1: Host 'win-host' is known and matches the RSA host key.
debug1: Found key in /home/deb-user/.ssh/known_hosts:2
debug2: bits set: 506/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/deb-user/cron/deb-rsync-key (0xb8f465c0)
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/deb-user/cron/deb-rsync-key
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
Connection closed by win-host
    
por bradypus 12.03.2013 / 10:54

1 resposta

0

Eu acho que o problema está nas suas authorized_keys, ou possivelmente que você não tem o rsync instalado no servidor .

Verifique se o rsync está instalado primeiro, então vamos tentar resolver o problema em etapas:

Primeiro, vamos nos livrar de from = e command = , assim podemos ver se ele pode se conectar usando a chave.

A linha resultante deve ficar assim:

ssh-dss AAAAB3NzaC1kc3MAAAEBA ..

Então vamos ver se podemos nos conectar usando o ssh diretamente.

ssh -i [path-to-key] win-user@win-host

Se isso funcionar, vamos adicionar ip = , verificar se o IP do cliente está se conectando.

ip="[client-ip]" ssh-dss AAAAB3NzaC1kc3MAAAEBA ..

Tente se conectar novamente usando o comando ssh acima.

Por fim, vamos adicionar nosso validate-rsync .

ip="[client-ip]",command="/home/remoteuser/cron/validate-rsync" ssh-dss AAAAB3NzaC1kc3MAAAEBA ..

Agora, com o uso de / home / remoteuser / cron / validate-rsync , você não poderá usar ssh diretamente, já que o script impede o shell padrão (definido em < strong> / etc / passwd ).

validate-rsync é usado para evitar todos os comandos, exceto rsync --server . Em vez disso, você deve tentar um simples rsync do cliente para o servidor.

touch test && rsync -vv -e "ssh -i path-to-key" test win-user@win-host

Também pode ser relacionado ao cygwin, confira esta mensagem:

link .

    
por 12.03.2013 / 12:24

Tags