Ubuntu

公鑰的Gitosis安裝不起作用

  • June 29, 2011

我一直在按照本教程使用 Windows 7 作為客戶端在 Ubuntu Server 10.04 上安裝和設置 git。然而,在最終弄清楚它是如何工作的(在錯誤的鍵上執行了很多次 gitosis-init )之後,我將文件複製到id_rsa.pub文件夾中的伺服器/tmp並再次執行它。

不幸的是它仍然不起作用,當我執行時

git clone gitosis@yourserver.com: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:

根據這個聊天討論,可能的原因是:

  • 的值HOME(正確設置為/C/Users/UserName
  • 與用於各種命令的 shell 相比(Cygwin,因為它有ssh-copy-id命令,與 msysgit bash shell 相反)

由於ssh-copy-id僅將一行複製到文件中(請參閱“ ssh-copy-id and duplicates in 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作為路徑。

  1. 在 MingW " ssh-keygen -t rsa" 中創建 RSA 密鑰,並允許文件名中的預設設置並分配正確的密碼。

  2. 是否“ 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
  1. 安裝 git-core 和 gitosis 並執行“ sudo -H -u gitosis gitosis-init < /tmp/id_rsa.pub

6)id_rsa使用 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”終於成功了!

引用自:https://serverfault.com/questions/284683