lftp mget with wildcard returns '550 access denied' error

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) 7
  • lftp-4.4.8-8.el7_3.2

Issue

When using lftp mget command to get multiple files from a FTP server, the server returns

550 access denied

error, even though lftp get command on a single file works just fine.

Resolution

Use lftp with option

set ftp:use-tvfs yes

Root Cause

This is usually the case when using a wildcard with mget, e.g. mget /path/to/files/file*.ext. This happens on systems, where the client has access to the directory with the files, but cannot access the parent directory (this issue was observed when connecting via lftp to a Windows FTP server).

This is caused by the fact that lftp by default splits the /path/to/files into separate directories and tries to access it one by one:

]# cd /path
/path]# cd /to
/path/to]# cd /files
/path/to/files]#

The tvfs option assures that the desired directory is accessed through the full path:

]# cd /path/to/files
/path/to/files]#

Diagnostic Steps

Try running the lftp with -d option to see the debug output. In this output, you will see the feature list provided by the server. This might look like this:

---- Connecting to XXXXX (YY.YY.YY.YY) port 21
<--- 220 FTP Server ready.
---> FEAT
<--- 211-Features:
<---  AUTH TLS
...
<---  TVFS
...

If the string TVFS is not in the list of features provided by the server, try using lftp with option set ftp:use-tvfs yes.

Another method how to find out if this is the case is to connect to the FTP server and use cd command to get to some of the parent directories:

lftp user@someftpserver:~> cd /path
cd: Access failed: 550 Access is denied.  (/path)
lftp user@someftpserver:~> cd /path/to
cd: Access failed: 550 Access is denied.  (/path/to)

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments