Gitosis 安装公钥不起作用

Gitosis 安装公钥不起作用

我一直在关注本教程使用 Windows 7 作为客户端在 Ubuntu Server 10.04 上安装和设置 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}(最后几行显示从公钥切换到密码的位置):

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

答案1

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

  • 的值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,snce$HOME指的是/c/Users/UserName/
  • 手动将 id_rsa.pub 的内容复制到~/.ssh/authorized_keys服务器(因为这里可以直接访问该服务器)。

OP user29600 已修复此问题!

1)确保将其HOME作为环境变量用作C:\Users\UserName路径。

2)在MingW“ ”中创建RSA密钥ssh-keygen -t rsa并允许文件名使用默认设置并分配适当的密码。

3) 执行“ ssh-copy-id -i $HOME/.ssh/id_rsa.pub {USER}@{SERVER_IP}”以确保已为该用户启用 RSA 密钥认证。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

id_rsa6)使用 MingW 时出现文件权限错误。
发现本文也就是说将ssh.exe文件从复制C:\cygwin\binC:\Program Files\Git\bin并覆盖文件,包括必要的.dll文件。
此步骤是因为 MingW 没有正确设置或读取 chmods... cygwin 显示 600,MingW 显示 644。
复制文件后ssh.exe,我能够正确地chmod使用 MingW 处理文件,权限错误消失了。

7)“ git clone gitosis@{SERVER_IP}:gitosis-admin.git”终于起作用了!

相关内容