我想通过FTP访问远程服务器上的GIT存储库。由于某些不幸的原因,服务器只允许主动模式FTP而不是被动模式。即如果我用卷曲(由git clone
使用同一个客户端)直接下载一个文件,下面的命令作品:在git-clone期间使用主动模式FTP而不是被动模式?
curl -P - ftp://user:[email protected]/file
但服用-P -
出来会造成卷曲挂起,直到超时。
问题是我不知道如何告诉git clone
使用主动模式的FTP。当我设置GIT_CURL_VERBOSE=1
并做了git clone ftp://user:[email protected]/repo
,我注意到它发送的是PASV
而不是PORT
,并且挂起时就像没有使用-P -
开关的卷曲一样。我如何告诉它做其他事情?我读了一些关于_netrc
的文件,但找不到通过它设置活动模式的示例。
对于任何好奇,这里是从git clone
冗长卷曲输出(几乎一样运行curl
不指定-P -
选项。)
* About to connect() to server.com port 21 (#0)
* Trying {server ip}... * 0x98d548 is at send pipe head!
* Connected to server.com ({server ip}) port 21 (#0)
< 220 Microsoft FTP Service
> USER User
< 331 Password required for User.
> PASS {pass}
< 230 User User logged in.
> PWD
< 257 "/User" is current directory.
* Entry path is '/User'
> CWD repo.git
< 250 CWD command successful.
> CWD info
< 250 CWD command successful.
> EPSV
* Connect data stream passively
< 500 'EPSV': command not understood
* disabling EPSV usage
> PASV
< 227 Entering Passive Mode ({server ip},10,137).
* Trying {server ip}... * Connecting to {server ip} ({server ip}) port 2697
/* server hangs from here until time-out */
随着卷曲指定的-P -
选项,PORT
命令将代替使用PASV
,因此从EPSV
线下面的命令将被发送,而不是向服务器开始:
> EPRT |1|{client ip}|13375|
< 500 'EPRT |1|{client public ip}|36093|': command not understood
* disabling EPRT usage
> PORT {client ip},52,64
< 200 PORT command successful.
* Connect data stream actively
> TYPE I
< 200 Type set to I.
> SIZE file
< 213 213
> RETR file
< 150 Opening BINARY mode data connection for file(213 bytes).
/* and the file just downloads from here. */
我的配置:msysgit,MS-FTP服务器。
服务器是否支持EPSV模式? – CharlesB
不,它不。 'EPSV'实际上是在回退到'PASV'之前尝试的第一个命令'git clone'。 – ydyu
你有什么想法,为什么它挂着git,而不是'curl -P'? – CharlesB