SFTP - Error with encripted variable

Hi everyone.
I’m triying to upload mi project to a custom SFTP server. Currently, I’m using a Ubuntu Focal enviroment.
To build the URL, I encrypt the following with the travis-ci cli, using travis encript --pro command:

  • The user - SFTP_USER
  • The password - SFTP_PASSWORD
  • My public IP adress: SFTP_DOMAIN
  • The directory where I want to store the project: SFTP_DIRECTORY

The travis.yml file looks like:

 env:
  global:
   - secure ....
   - secure ...
   - secure ...
   - SFTP_KEY. I generate it in the server with the command "ssh-keygen", so I don't re-encrypt this key.

The problem comes when the build reach the after_success stage and run the following:

    - echo "${SFTP_KEY}" | base64 --decode > /tmp/sftp_rsa
    - cd $HOME/.m2/repository/acme
    - zip -r acme.zip acme-tfg
    - curl -T acme.zip --key /tmp/sftp_rsa sftp://${SFTP_USER}: {SFTP_PASSWORD}@{SFTP_DOMAIN}/{SFTP_DIRECTORY}/acme.zip

The last command exits with a “curl: (6) Could not resolve host: SFTP_DOMAIN”.
I suppose the other variables are correctly desencripted, but it seems that travis doesn´t desencripted the SFTP_DOMAIN variable and cURL doesn´t be able to connect. I’m right? Or maybe I cannot encrypt the IP adress? Maybe some configuration is missing?
I followed this doc page: https://docs.travis-ci.com/user/deployment/custom/
Thanks in advance.

$VAR or ${VAR} are Bash’s variable substitution syntax. You are missing the dollar signs in a few places in the command you posted.

You’re right. I missed some dollar signs in my code. Now, the cURL command ends with “curl: (28) Failed to connect to [secure] port 22: Connection timed out” .
I tried the command in my local terminal and works(using the private IP adress of my server and also the public IP from my router), so I don’t understand what’s is happend in the build.
Thanks.

Can’t say without some info where you’re connecting. If it’s a publicly available external server, this is most probably a network connectivlty issue or packet filtering at the remote server. See e.g.

for the tools you can use to diagnose network problems.

Hi.
Now all is alright. The problem was my NAT configuration, which doesn’t allow the travis connection.
Thanks for all.

1 Like