A instalação da chave pública não funciona

1

Eu tenho seguido este tutorial para instalar e configurar o git no Ubuntu Server 10.04 usando o Windows 7 como um cliente. No entanto, depois de finalmente descobrir como funciona (executei gitosis-init várias vezes na tecla errada), copiei o arquivo id_rsa.pub para o servidor na pasta /tmp e executei-o novamente.

Infelizmente, ainda não funciona e quando executo

git clone [email protected]:gitosis-admin.git

ele pede a senha de gitosis em vez da senha RSA. Eu estou supondo que é o mesmo problema esse cara está tendo aqui ... no entanto, depois de seguir suas instruções:

Limpe o git-core e a gitosis e remova manualmente a pasta / srv / gitosis

e seguindo as instruções novamente (com o arquivo id_rsa.pub correto desta vez), eu ainda estou tendo o mesmo problema.

Alguém sabe o que estou fazendo errado? Existe alguma maneira de investigar mais informações que possam ajudar a resolver isso?

Editar: saída de ssh -vvv gitosis@{IP_ADDRESS} (as últimas linhas mostram onde está mudando de publickey para senha):

{UserName}@{COMPUTERNAME} ~
$ ssh -vvv gitosis@{IP_ADDRESS}
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug2: ssh_connect: needpriv 0
debug1: Connecting to {IP_ADDRESS} [{IP_ADDRESS}] port 22.
debug1: Connection established.
debug1: identity file /c/Users/{UserName}/.ssh/identity type -1
debug3: Not a RSA1 key file /c/Users/{UserName}/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug2: key_type_from_name: unknown key type 'Proc-Type:'
debug3: key_read: missing keytype
debug2: key_type_from_name: unknown key type 'DEK-Info:'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
# Repeated 23 times here...
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /c/Users/{UserName}/.ssh/id_rsa type 1
debug1: identity file /c/Users/{UserName}/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3p1 Debian-3ubuntu6
debug1: match: OpenSSH_5.3p1 Debian-3ubuntu6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
# Bunch of stuff here that doesn't seem important... I can include if necessary
debug3: check_host_in_hostfile: filename /c/Users/{UserName}/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host '192.168.0.113' is known and matches the RSA host key.
debug1: Found key in /c/Users/{UserName}/.ssh/known_hosts:1
debug2: bits set: 526/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: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /c/Users/{UserName}/.ssh/identity (0x0)
debug2: key: /c/Users/{UserName}/.ssh/id_rsa (0xa01a428)
debug2: key: /c/Users/{UserName}/.ssh/id_rsa (0x0)
debug1: Authenications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Trying private key: /c/Users/{UserName}/.ssh/identity
debug3: no such identity: /c/Users/{UserName}/.ssh/identity
debug1: Offering public key: /c/Users/{UserName}/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /c/Users/{UserName}/.ssh/id_dsa
debug3: no such identity: /c/Users/{UserName}/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password #it just switched to password...
debug3: remaining_preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
gitosis@{IP_ADDRESS}'s password:
    
por user29600 28.06.2011 / 00:11

1 resposta

1

De acordo com esta discussão de chat , a causa possível foi:

  • o valor de HOME (definido corretamente como /C/Users/UserName )
  • versus o shell usado para os vários comandos (Cygwin, porque ele tinha o comando ssh-copy-id , ao contrário do shell bash do msysgit)

Como ssh-copy-id apenas copia uma linha para um arquivo (consulte " ssh-copy-id e duplicatas em authorized_keys ", foi mais simples:

  • gere as chaves rsa em uma sessão bash msysgit (as chaves serão criadas em /c/Users/UserName/.ssh/id_rsa , snce $HOME refere-se a /c/Users/UserName/ )
  • copie manualmente o conteúdo de id_rsa.pub para o ~/.ssh/authorized_keys do servidor (já que aqui é possível ter acesso direto ao dito servidor).

O OP user29600 corrigiu!

1) Made sure that HOME was in as an environment variable using C:\Users\UserName as the path.

2) Created the RSA keys in MingW "ssh-keygen -t rsa" and allowing for the default setting in file name and assigning a proper passphrase.

3) Did "ssh-copy-id -i $HOME/.ssh/id_rsa.pub {USER}@{SERVER_IP}" to ensure RSA key auth was enabled for that user. 4) sent the .pub file to the server using "

scp $HOME/.ssh/id_rsa.pub {USER}@{SERVER_IP}:/tmp

5) installed git-core and gitosis and executed "sudo -H -u gitosis gitosis-init < /tmp/id_rsa.pub"

6) Had an error about permissions on the id_rsa file when using MingW.
Found this article that said to copy the ssh.exe file from C:\cygwin\bin to C:\Program Files\Git\bin and overwrite the file, included the necessary .dll files.
This step was because MingW was not setting or reading chmods properly... cygwin showed 600, MingW showed 644.
After copying over the ssh.exe file, I was able to properly chmod the files with MingW and the permission error went away.

7) "git clone gitosis@{SERVER_IP}:gitosis-admin.git" finally worked!

    
por 29.06.2011 / 18:03

Tags