簡體   English   中英

GitHub / 私有存儲庫 / SSH:go get/go mod tidy fail,而 ZBA9F11ECC3497D999Z5 克隆正在工作

[英]GitHub / private repository / SSH: go get/go mod tidy fail, while git clone is working

我希望找到過去幾天困擾我的問題的答案 - 我已經閱讀了很多線程、助手和出版物,但似乎沒有找到解決方案。 我對 SSH 有點陌生。

The problem is as follows: I cannot get/install/refresh the modules belonging to my project, when using go get or go mod tidy commands, while git clone of the same repo via SSH in any of the terminals or via TortoiseGit are working fine ,即我可以克隆,但我不能構建。

獲取模塊以下列方式失敗(個人數據被混淆):

    example.com/hello/PROJECTS/src/git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources tested by
    example.com/hello/PROJECTS/src/git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources.test imports
    git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources/vm_specific: module git.<orgname>.com/<reponame>/<subreponame>/tests/functional/resources/vm_specific: git ls-remote -q origin in C:\GO\PROJECTS\pkg\mod\cache\vcs\a5d519aeafc0ac08e2b20d7c8a6a8b2cea11cda88cb058cf2ebcc079d07b260a: exit status 128:
    debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> 'C:\\Users\\<username>/.ssh/known_hosts'
    debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> 'C:\\Users\\<username>/.ssh/known_hosts2'
    debug2: resolving "git.<orgname>.com" port <port>
    debug3: resolve_host: lookup git.<orgname>.com:<port>
    debug3: ssh_connect_direct: entering
    debug1: Connecting to git.<orgname>.com [10.XXX.X.XX] port <port>.
    debug1: Connection established.
    ...
    debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.9
    debug1: Remote protocol version 2.0, remote software version APACHE-SSHD-2.4.0
    debug1: compat_banner: no match: APACHE-SSHD-2.4.0
    debug2: fd 3 setting O_NONBLOCK
    debug1: Authenticating to git.<orgname>.com:<port> as 'git'
    ...
    debug1: Authentications that can continue: publickey
    ...
    debug3: send packet: type 50
    debug3: receive packet: type 52
    Authenticated to git.<orgname>.com ([10.XXX.X.XX]:<port>) using "publickey".
    ...
    debug1: Sending command: git-upload-pack '/scm/<reponame>/<subreponame>.git'
    debug2: channel 0: request exec confirm 1
    debug3: send packet: type 98
    debug2: channel_input_open_confirmation: channel 0: callback done
    debug2: channel 0: open confirm rwindow 2097152 rmax 32768
    debug3: receive packet: type 99
    debug2: channel_input_status_confirm: type 99 id 0
    debug2: exec request accepted on channel 0
    debug2: channel 0: rcvd ext data 106
    debug3: receive packet: type 96
    debug2: channel 0: rcvd eof
    debug2: channel 0: output open -> drain
    debug3: receive packet: type 98
    debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    debug3: receive packet: type 97
    debug2: channel 0: rcvd close
    debug2: chan_shutdown_read: channel 0: (i0 o1 sock -1 wfd 4 efd 6 [write])
    debug2: channel 0: input open -> closed
    debug3: channel 0: will not send data after close
    debug2: channel 0: obuf_empty delayed efd 6/(106)
    debug2: channel 0: written 106 to efd 6
    Repository not found
    The requested repository does not exist, or you do not have permission to access it.
    debug3: channel 0: will not send data after close
    debug2: channel 0: obuf empty
    debug2: chan_shutdown_write: channel 0: (i3 o1 sock -1 wfd 5 efd 6 [write])
    debug2: channel 0: output drain -> closed
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    debug2: channel 0: almost dead
    debug2: channel 0: gc: notify user
    debug2: channel 0: gc: user detached
    debug2: channel 0: send close
    debug3: send packet: type 97
    debug2: channel 0: is dead
    debug2: channel 0: garbage collecting
    debug1: channel 0: free: client-session, nchannels 1
    debug3: channel 0: status: The following connections are open:
      #0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/6 sock -1 cc -1 io 0x00/0x08)

    debug3: send packet: type 1
    Transferred: sent 3268, received 2200 bytes, in 0.2 seconds
    Bytes per second: sent 15169.6, received 10212.1
    debug1: Exit status 1

如果需要更完整的日志,我可以將其上傳到某個地方。

最后一行ssh -T(vvv set as default) git@git.<orgname>.com

    debug3: send packet: type 50
    debug3: receive packet: type 52
    debug1: Authentication succeeded (publickey).
    Authenticated to git.<orgname>.com ([10.XXX.X.XX]:<port>).
    debug1: channel 0: new [client-session]
    debug3: ssh_session2_open: channel_new: 0
    debug2: channel 0: send open
    debug3: send packet: type 90
    debug1: Entering interactive session.
    debug1: pledge: filesystem full
    debug3: receive packet: type 91
    debug2: channel_input_open_confirmation: channel 0: callback start
    debug2: fd 3 setting TCP_NODELAY
    debug3: set_sock_tos: set socket 3 IP_TOS 0x08
    debug2: client_session2_setup: id 0
    debug2: channel 0: request shell confirm 1
    debug3: send packet: type 98
    debug2: channel_input_open_confirmation: channel 0: callback done
    debug2: channel 0: open confirm rwindow 2097152 rmax 32768
    debug3: receive packet: type 100
    debug2: channel_input_status_confirm: type 100 id 0
    shell request failed on channel 0

我正在使用從 OpenSSH 的 ssh-keygen 生成的密鑰派生的公鑰 - 它是新生成的,並已添加到我的 Git 配置文件中。 git clone工作正常,這已經讓我發瘋了。 我已經有了大部分無法在遠程私有倉庫中檢查的模塊,這更瘋狂。

我不喜歡這部分,這很可能意味着我的證書有問題 -

使用“公鑰”對 git..com ([10.XXX.X.XX]:) 進行了身份驗證。

這部分,因為OpenSSH on AIX requests PKCS12 support by default when EFS is enabled and non-AIX systems may reject these PKCS12 requests.

 debug2: channel 0: obuf_empty delayed efd 6/(106) debug2: channel 0: written 106 to efd 6

請參閱下面我的配置中的更改。

我的環境:

  • Win10企業版
  • Git 版本 - 2.31.1.windows.1
  • 我通常通過 TortoiseGit 2.13.0.1 克隆
  • SSH 客戶端在 CMD/Powershell 中使用 - OpenSSH_for_Windows_8.9,手動安裝

go env:(個人數據混淆)

    set GO111MODULE=
    set GOARCH=amd64
    set GOBIN=
    set GOCACHE=C:\Users\<username>\AppData\Local\go-build
    set GOENV=C:\Users\<username>\AppData\Roaming\go\env
    set GOEXE=.exe
    set GOEXPERIMENT=
    set GOFLAGS=
    set GOHOSTARCH=amd64
    set GOHOSTOS=windows
    set GOINSECURE=
    set GOMODCACHE=C:\Program Files\Go\pkg\mod
    set GONOPROXY=*.<orgname>.com;git.<orgname>.com/users/<username>
    set GONOSUMDB=*.<orgname>.com;git.<orgname>.com/users/<username>
    set GOOS=windows
    set GOPATH=C:\Program Files\Go
    set GOPRIVATE=*.<orgname>.com;git.<orgname>.com/users/<username>
    set GOPROXY=https://proxy.golang.org,direct
    set GOROOT=C:\Program Files\Go
    set GOSUMDB=sum.golang.org
    set GOTMPDIR=
    set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
    set GOVCS=
    set GOVERSION=go1.18.3
    set GCCGO=gccgo
    set GOAMD64=v1
    set AR=ar
    set CC=gcc
    set CXX=g++
    set CGO_ENABLED=1
    set GOMOD=NUL
    set GOWORK=
    set CGO_CFLAGS=-g -O2
    set CGO_CPPFLAGS=
    set CGO_CXXFLAGS=-g -O2
    set CGO_FFLAGS=-g -O2
    set CGO_LDFLAGS=-g -O2
    set PKG_CONFIG=pkg-config
    set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\USER~1.NAM\AppData\Local\Temp\go-build1143995380=/tmp/go-build -gno-record-gcc-switches

我的 SSH 配置:

    # GITHUB FOR SRC
        Host git.<orgname>.com
           ServerAliveInterval 600
           TCPKeepAlive yes
           IPQoS throughput
           AddKeysToAgent yes
           HostName git.<orgname>.com
           Port <port>
           User <username>
           PreferredAuthentications publickey
           IdentityFile C:\Users\<username>\.ssh\git_rsa
           #IdentityFile ~/.ssh/git_rsa
           PubkeyAcceptedKeyTypes +ssh-rsa
           #ForwardAgent no
           #AllowPKCS12KeystoreAutoOpen no
           LogLevel DEBUG3
  • 證書之前是加到代理里的,不過我這里指定了是為了確定,根據日志好像取到了正確的證書進行認證。

  • 它沒有密碼。

  • 我的known-hosts中沒有完全未知的條目,並且正在使用通過證書時間戳判斷的正確條目。

  • 我發現可以通過將AllowPKCS12KeystoreAutoOpen設置為no來禁用 PKCS12 請求,但它被標記為錯誤選項 -

     C:\GO\PROJECTS\src\git.<orgname>.com\<reponame>\<subreponame>>go get git.<orgname>.com/<name>/go-service/log go: module git.<orgname>.com/<name>/go-service/log: git ls-remote -q origin in C:\GO\PROJECTS\pkg\mod\cache\vcs\d0d607237eeba0d1c9d5ce996ed36c0f3746b2c8f94b538ace2d3f2a9476839e: exit status 128: C:\\Users\\<username>/.ssh/config: line 15: Bad configuration option: allowpkcs12keystoreautoopen C:\\Users\\<username>/.ssh/config: terminating, 1 bad configuration options

GIT 配置:

  • 全球的:

     [user] name = <username> email = <usrname>@<orgname>.com [url "ssh://git@git.<orgname>.com:<port>/"] insteadOf = https://git.<orgname>.com
  • 系統:

     [url "ssh://git@git.<orgname>.com:<port>/"] insteadOf = https://git.<orgname>.com/

git 遠程-v:

    origin  ssh://git@git.<orgname>.com:<port>/~<username>/<subreponame>.git (fetch)
    origin  ssh://git@git.<orgname>.com:<port>/~<username>/<subreponame>.git (push)
  • 我用來克隆的一樣,

回購配置:

    [remote "origin"]
        url = ssh://git@git.<orgname>.com:<port>/~<username>/<subreponame>.git
        fetch = +refs/heads/*:refs/remotes/origin/*

我嘗試了 ssh:// 和 git@git... 並沒有幫助。

模塊配置(自動設置),但是:

    [remote "origin"]
        url = https://git.<orgname>.com/scm/<reponame>/<subreponame>.git
        fetch = +refs/heads/*:refs/remotes/origin/*

我現在沒有想法。

我建議不要將go get與私有存儲庫一起使用。 此命令將存儲庫緩存在 pkg.go.dev 中,從而將它們公開給全世界。 我很尷尬地發現我們的私人開發項目在那里公開發表。

我在文件系統中手動部署我的私有依賴項,並使用替換在go.mod中指定依賴項:

require your.server/your/package 1.2.3

replace your.server/your/package 1.2.3 => /path/to/local/your/package

這是存儲庫的一個問題 - 它並不是真正用於處理依賴項,也不是用於處理模塊和與模塊相關的請求。 C'est la vie,但至少我學到了很多關於 SSH 和 GIT 交互的知識。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM