1

我在 Ionos.com 有一个 FTP 服务器,它与 Filezilla 配合得很好。但是,当我尝试在 gitlab 公共运行器(节点:最新图像)上通过 LFTP 连接到此 FTP 服务器时,我不断收到错误,具体取决于我在做什么:

在端口 21 上连接:

lftp -d -e "set ftp:ssl-allow no;set ssl:verify-certificate false;set sftp:auto-confirm no;ls;" -u 'xxx','xxx' -p 21 'xxx'

---- Resolving host address...
---- 2 addresses found: xxx, xxx
---- Connecting to xxx (xxx) port 21
**** Socket error (Network is unreachable) - reconnecting
---- Closing control socket
---- Connecting to xxx (xxx) port 21
<--- 220 FTP Server ready.
---> FEAT
<--- 500 'FEAT': command unrecognized.
---> USER xxx
<--- 331 Password required for xxx
---> PASS xxx
<--- 530 Login incorrect.
---> PWD
ls: Login failed: 530 Login incorrect.
<--- 421 Service not available, closing control connection.
---> QUIT
<--- 530 Not logged in.
---- Closing control socket

在端口 22 上连接:

lftp -d -e "set ftp:ssl-allow yes;set ssl:verify-certificate true;set sftp:auto-confirm yes;ls;" -u 'xxx','xxx' -p 22 'xxx'

---- Resolving host address...
---- 1 address found: xxx
---- Connecting to xxx (xxx) port 22
<--- SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u1~ui10+2
**** Peer closed connection
---- Closing control socket

最后 4 行循环令人作呕。

我已经通过在 Filezilla 上测试凭据和服务器主机来检查凭据和服务器主机是否良好。

有人能帮我吗 ?谢谢

4

2 回答 2

0

问题是 FTP 需要 SFTP 连接。

为了让 LFTP 在 SFTP 中连接,我们需要在主机名前使用“sftp://”。

lftp -d -e "set ftp:ssl-allow yes;set ssl:verify-certificate true;set sftp:auto-confirm yes;ls;" -u 'xxx','xxx' -p 22 'sftp://xxxx'
于 2020-12-01T16:10:08.907 回答
0

我花了一段时间才让它工作,这是我的解决方案:

deploy:
  script:
    - apt-get update -qq && apt-get install -y -qq lftp
    - mkdir ~/.ssh/
    - ssh-keyscan -t rsa homexxxxxxx.1and1-data.host >> ~/.ssh/known_hosts
    - lftp -d -e "set ftp:ssl-allow yes;set ssl:verify-certificate true;set sftp:auto-confirm yes;ls;" -u $USERNAME,$PASSWORD -p 22 'sftp://homexxxxxxx.1and1-data.host' -e "mirror -e -R -x .git -p ./ ; quit"
  only:
    - master

如果没有该行ssh-keyscan -t rsa homexxxxxxx.1and1-data.host >> ~/.ssh/known_hosts,gitlab 运行程序将返回host key verification failed错误。

于 2022-03-01T20:36:33.333 回答