Ftp – Weird file corruption when using FTP. Any theories

corruptionftp

Sometimes when I'm uploading a large number of small files via FTP, some of the files' contents will be replaced with FTP control messages. For example, after uploading a website I'll notice that an image isn't displaying. When I examine the image on the server, I find that its contents have been replaced with something like

Response:   125 Data connection already open; Transfer starting.
Response:   226 Transfer complete.
Status:     Directory listing successful

It's very difficult to reproduce. Any corrupted files that I notice, I can usually just retransfer them. If I retransfer the whole site, maybe different files will be corrupted, maybe none at all.

This problem has been plaguing me for several years, and in that time I've replaced my computer (twice), my router, my cable modem, and I've moved halfway accross the country. I haven't had the problem recently, but that's probably only because I've learned ways of avoiding it, like zipping everything up before transferring it. I use FileZilla, by the way.

I discribed the problem to one of my web hosts once. They'd never heard of anything like it, didn't have a clue. I would love to know what's been going on. As it is, I'm very leery about using FTP for anything more than a handful of files.

Best Answer

Very simply: the universe (and/or Murphy) is punishing you for continuing to use a thoroughly obsolete and insecure protocol like FTP.

When you connect to your web server using FTP, your username and password are sent unencrypted, in the clear, for everyone and Big Brother to read. So are the contents of all the files that you upload or download using FTP. For security reasons alone, I would strongly suggest switching to SFTP, which is a built-in feature of SSH. Any web hosting provider worth your business supports SSH and SFTP.

Any FTP problems that you may be experiencing on the server side almost certainly will not apply when using SFTP, because SFTP connections are handled by a completely separate daemon/service on the server.

Unlike FTPS, FTPES, etc., SSH/SFTP implementations are very consistently interoperable. You are unlikely to experience strange and unpredictable problems when transferring files via SFTP.