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.
ftp>


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: ,