10 September 2009

An FTP error and fix

Of all the things you'd expect to "just work", the venerable ftp should be near the top of the list. But, it's been giving me some trouble lately. I've been having to upload some files to another organization's servers. and getting strange errors like this one:

425 Unable to build data connection: Invalid argument

It took a bit of digging, but in this case it turns out that the extended EPSV and EPRT commands were the issue. I don't know what those extensions are, but they are on by default in the FreeBSD client and ProFTPD 1.3.2 Server doesn't seem to like them. The solution is easy enough, from your client's 'ftp>' prompt just toggle the mode to off with this command (command portion bolded):

ftp> epsv4
EPSV/EPRT on IPv4 off.

And notice the response. (Since it's a toggling command, you could be turning it on).

Now the trick is, if you're regularly using a server that has issues with EPSV, to get it turned off by default, so you need not type it every time and could even script your transfers. For that, we're going to need the ".netrc" file. An entry like this should do it:

machine funkyserver.example.com
macdef init
epsv4 off

default ...

I put the default in there only to make it clear that you need a blank line to terminate the "init" macro! "default" is not required; blank line at end of macro is.

Labels: ,


At 11/11/09 15:56, Anonymous Anonymous said...

Looks like the EPSV and EPRT are related to IPV6 and NAT. It might be a bug on how the client negotiates a connection to the server. Perhaps the *nix Box using ProFTPD isn't configured for IPV6 or nat'ng properly. ProFTBD is suppose to support IPV6 according to their home page.

So, where is the potential bug/issue ? Is it in ProFTPD or in the BSD client? Could be a NAT config issue.

I think this would a question for the mailing list? Then potentially opening a PR.

PS: Packet dump would also be nice. I guess you already did that since you got the EPSV and EPRT messages.


I can't help it; it's kind of like a Scooby Doo Mystery.

PS: It might be the mean old man that owns the amusement park; he wears a rubber mask ya know.

As always, I really enjoy the blog. Keep up the great work.


At 16/11/09 22:48, Blogger kace said...

Thank you very much.

I didn't get a dump. Was under pressure to get things moved. May have been a mail list that pointed me in the right direction. (And then "man ftp"!) But, the simple error+answer was not out there, so I thought it would make it a good post.

Anyway, I settled for the work-around. But, I'd bet that a dump probably would solve this mystery. "... If it weren't for those darn kids!"

At 27/11/09 12:41, Anonymous Anonymous said...

This comment has been removed by a blog administrator.


Post a Comment

<< Home