简体   繁体   中英

.gitlab-ci.yml Gitlab Deploy SFTP Not Working

deploy:
  stage: deploy
  script:
    - apt-get update -qq && apt-get install -y -qq lftp
    #- lftp -u $DEPLOY_USER,$SFTP_PASSWORD $DEPLOY_HOST -e "mirror -e -R -p ./dist/ new/ ; quit"
    - lftp -c "set ftp:ssl-allow no; debug; open -u root,$DEPLOY_PASSWORD -p 22 $DEPLOY_HOST; mirror -Rev ./ gitlab --verbose --ignore-time --parallel=10 --exclude-glob .git* --exclude .git/"
    - echo "deployment complete"
  # specify environment this job is using
  environment:
    name: staging
    url: https://xxxxxxxx.de/
  # needs artifacts from previous build

Why does the preceding .gitlab-ci.yml create the following error?

new Fail ->

--verbose --ignore-time --parallel=10 --exclude-glob .git* --exclude .git/"
---- Running connect program (ssh -a -x -s -l root xx.xx.xxx.xx sftp)
---> sending a packet, length=5, type=1(INIT), id=0
<--- The authenticity of host 'xx.xx.xxx.xx (xx.xx.xxx.xx)' can't be established.
<--- ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxx+xxxxxxxxxxxxxx.
<--- Are you sure you want to continue connecting (yes/no)? no
<--- 
<--- Host key verification failed.
---- Disconnecting
---- Running connect program (ssh -a -x -s -l root xx.xx.xxx.xx sftp)
---> sending a packet, length=5, type=1(INIT), id=0
<--- The authenticity of host 'xx.xx.xxx.xx (xx.xx.xxx.xx)' can't be established.
<--- ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxx+xxxxxxxxxxxxx.
<--- Are you sure you want to continue connecting (yes/no)? no
<--- 
<--- Host key verification failed.
mirror: Fatal error: Host key verification failed.
---- Disconnecting
ERROR: Job failed: exit code 1

You have set ftp:ssl-allow no , but you are connecting to port 22 which is most likely an SSL service.

Assuming you intend to use SSL for the connection. Try: set ftp:ssl-allow true; as part of the lftp command.

The lftp man page states:

ftp:ssl-allow (boolean) if true, try to negotiate SSL connection with FTP server for non-anonymous access. Default is true. This and other SSL settings are only available if lftp was compiled with an ssl/tls library.

lftp -c "set ftp:ssl-allow no; debug; open -u root,$DEPLOY_PASSWORD -p 22 $DEPLOY_HOST…"

1st, remove set ftp:ssl-allow no; or set it to yes .

2nd, you said "SFTP" in the title and use port 22; protocol SFTP is not FTP, it's a completely different protocol; to use it you've to make lftp to use the protocol by using URL with sftp:// protocol:

lftp -c "debug; open -u root,$DEPLOY_PASSWORD sftp://$DEPLOY_HOST…"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM