-1

I have a very old shell script running on a production machine i just got access to from my customer and my job is to convert it to a curl equivalent. The script is pretty simple and all it does is downloading a file from remote FTP to a local filesystem:

lftp -u Username,'pass' xxx.xxx.xx.xx << !
  echo 'Connected'
  get dir/file.csv
  exit
!

First of all - is that even possible to replace that with curl? It looks like a simple FTP fetching script to me but i might be not aware of any nuances of downloading FTP files using curl.

Second of all, here is what i tried so far based on dozen of threads i've found on the internet and none of these worked:

curl ftp://Username:pass@xxx.xxx.xx.xx/dir/file.csv --ftp-ssl
#=> curl: (67) Access denied: 550

curl ftps://Username:pass@xxx.xxx.xx.xx/dir/file.csv --ftp-ssl
#=> curl: (67) Access denied: 550

curl -P - --insecure "ftp://xxx.xxx.xx.xx/dir/file.csv" --user "Username:pass" --ftp-ssl
#=> curl: (67) Access denied: 550

Edit: after adding -v, i realized that there was some issue with the certificate so i added --insecure flag and it now tells that login was incorrect while I'm 100% sure both login and passwords are correct. Output:

*   Trying xxx.xxx.xx.xx...
* TCP_NODELAY set
* Connected to xxx.xxx.xx.xx (xxx.xxx.xx.xx) port 21 (#0)
< 220 NASFTPD Turbo station 1.3.5a Server (ProFTPD)
> AUTH SSL
< 234 AUTH SSL successful
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* Server certificate:
*  subject: C=TW; ST=xxx; L=xxx; O=xxx, Inc.; OU=xxx; CN=xxx; emailAddress=xxx
*  start date: Mar 11 10:45:27 2016 GMT
*  expire date: Mar  9 10:45:27 2026 GMT
*  issuer: C=TW; ST=xxx; L=Taipei; O=xxx, Inc.; OU=QTS; CN=xxx; emailAddress=xxx
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
> USER Username
< 331 Password required for Username
> PASS s
< 530 Login incorrect.
* Access denied: 530
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
curl: (67) Access denied: 530
mbajur
  • 4,406
  • 5
  • 49
  • 79

1 Answers1

0

The issue was caused by the fact that password contained a $ character which made password parsing misbehaving and was using just a first letter of a password (next one was a dollar sign). Wrapping password inside single quotation marks solved the issue for me.

mbajur
  • 4,406
  • 5
  • 49
  • 79