2

i've tried to create a script that will upload some file to a ftp server using lftp, but without any luck so far. If I used build in ftp command in debian I manage to succsessfully connected and put the file. Here is the debug output from lftp command:

lftp xxx.xxx.xxx.xxxx -e "put -O /out/ some_file_name" -d
---- using user `user01' and password from ~/.netrc
---- Resolving host address...
---- 1 address found:xxx.xxx.xxx.xxxx
---- Connecting to xxx.xxx.xxx.xxxx (xxx.xxx.xxx.xxxx) port 21
<--- 220 (vsFTPd 2.0.7)                                         
---> FEAT
<--- 211-Features:                                                    
<---  EPRT
<---  EPSV
<---  MDTM
<---  PASV
<---  REST STREAM
<---  SIZE
<---  TVFS
<---  UTF8
<--- 211 End
---> OPTS UTF8 ON
<--- 200 Always in UTF8 mode.                                   
---> USER user01
<--- 331 Please specify the password.                           
---> PASS XXXX
<--- 230 Login successful.                                            
---> PWD
<--- 257 "/"                                                              
---> TYPE I
<--- 200 Switching to Binary mode.                                        
---> EPSV
<--- 550 Permission denied.                                               
---- Switching passive mode off
---- Closing data socket
---- Closing control socket

As you can see I'm using stored user name and password from .netrc file. I have another script that connect to the same server but uploads files and rename them inside the remote ftp folder using lftp again. Can someone help and explain why I cannot put with lfpt but can do it using ftp.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Vasil Ivanov
  • 91
  • 1
  • 1
  • 9
  • What happens if you just script the built-in debian command? – Robert Harvey Jul 05 '18 at 22:04
  • I'm using 'mv' command from lfpt, cause by specification must upload a file and when it is complete i must renaming it. For example - "put Xsome_file_name -O /some_remote_dir/ " and after that "cd /some_remote_dir/; mv Xsome_file_name some_file_name". Also I didnt find a way to upload a file using one line command that upload the file to some remote directory using only ftp. – Vasil Ivanov Jul 05 '18 at 22:26

3 Answers3

3

after add set ftp:passive-mode true and set ftp:prefer-epsv false to /etc/lftp.conf the error is changed

<--- 230 Login successful.                                            
---> PWD
<--- 257 "/"                                                              
---> TYPE I
<--- 200 Switching to Binary mode.                                        
---> PASV
<--- 227 Entering Passive Mode (xxx.xxx.xxx.xxx,76,92)                      
---- Connecting data socket to (xxx.xxx.xxx.xxx) port 19548
---- Data connection established                                            
---> ALLO 710
<--- 550 Permission denied.                                               
---> STOR out/my_file_name
---> ABOR
put: Access failed: 550 Permission denied. (/out/my_file_name)
---- Closing aborted data socket
---- Closing control socket

Okay I've understand what ALLO means

The ALLO command may be sent to a server that requires the necessary space for an uploaded to be reserved before the transfer takes place

so after a quick search in ftp man page, I've found a command to shut it down. After adding set ftp:use-allo false and with epsv false everything is fine now. Thanks alot :)

Vasil Ivanov
  • 91
  • 1
  • 1
  • 9
3

lftp -e "set ftp:use-allo false; set ftp:passive-mode true; set ftp:prefer-epsv false; mirror -R {local dir} {remote dir}" -u {username},{password} {host}

Use this single command to sync your file from local to server without 550 permission error.

Savin-Max
  • 61
  • 2
1

While 550 Permission denied. is a strange response to the EPSV command it means that the server or some middlebox in between does not understand the EPSV command (likely a middlebox since the response to FEAT shows EPSV as supported). If you use the builtin ftp command instead of lftp it will probably use the older PASV command (IPv4 only) instead of the newer EPSV command (IPv4+IPv6 capable).

According to the man page there is a setting ftp:prefer-epsv which should default to false. Maybe some configuration is setting this value to true so that lftp will use EPSV instead of PASV. Check your settings (set -a inside lftp) and if it is true (expected) set it to false and try again, in the hope that it will then use PASV instead of EPSV.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172