Gitosis公共密钥安装不工作

我一直在关注这个教程 ,在Ubuntu Server 10.04上使用Windows 7作为客户端来安装和设置git。 但是,在终于弄清楚它是如何工作的(在错误的键上执行gitosis-init一堆)之后,我将id_rsa.pub文件复制到/tmp文件夹中的服务器并再次运行。

不幸的是,它仍然不工作,当我执行

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

它要求gitosis的密码,而不是RSA密码。 我假设这个人在这里有同样的问题…但是,按照他的指示:

清除git-core和gitosis并手动删除/ srv / gitosis文件夹

并再次按照说明 (这次与正确的id_rsa.pub文件),我仍然有同样的问题。

任何人都知道我在做什么错了? 有没有什么办法来探索可能有助于解决这个问题的更多信息?

编辑:输出从ssh -vvv gitosis@{IP_ADDRESS} (最后几行显示它从publickey切换到密码):

 {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: 

根据这个聊天讨论 ,可能的原因是:

  • HOME的值(正确设置为/C/Users/UserName
  • 与用于各种命令的shell(Cygwin,因为它有ssh-copy-id命令,与msysgit bash shell相反)

由于ssh-copy-id仅将一行复制到一个文件(请参阅“ ssh-copy-id并在authorized_keys中复制 ”),因此更简单:

  • 在msysgit bash会话中生成rsa密钥(密钥将在/c/Users/UserName/.ssh/id_rsa创build,snce $HOME引用/c/Users/UserName/
  • 将id_rsa.pub的内容手工复制到服务器的~/.ssh/authorized_keys (因为可以直接访问这个服务器)。

OP user29600修好了!

1)确保HOME是作为一个环境variables使用C:\Users\UserName作为path。

2)在MingW“ ssh-keygen -t rsa ”中创build了RSA密钥,并允许在文件名中进行默认设置并分配正确的密码。

3)“ ssh-copy-id -i $HOME/.ssh/id_rsa.pub {USER}@{SERVER_IP} ”确保为该用户启用了RSA密钥身份validation。 4)发送.pub文件到服务器使用“

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

5)安装git-core和gitosis并执行“ sudo -H -u gitosis gitosis-init < /tmp/id_rsa.pub

6)在使用MingW时,对于id_rsa文件的权限有错误。
find这篇文章说,将ssh.exe文件从C:\cygwin\bin复制到C:\Program Files\Git\bin并覆盖该文件,包含必需的.dll文件。
这一步是因为MingW没有正确设置或读取chmods,cygwin显示为600,MingW显示为644。
在复制ssh.exe文件后,我能够用MingW正确地chmod文件,并且权限错误消失了。

7)“ git clone gitosis@{SERVER_IP}:gitosis-admin.git ”终于成功了!