blog posts

An Introduction to FTP And errors

FTP is the back door of every website, when we go shopping we can live only outside of it and just the decoration, FTP is the back door to all of the junks and things that an owner doesn’t want you to see, so they put a lock on that door so no one can enter it except themselves, FTP is a protocol which connects for file transferring between a host or a server to a client or user, FTP is most commonly used to download files from the
World Wide Web.

It is a choice to the HTTP protocol for downloading and uploading files to FTP servers.

History of FTP

in the early day of publishing desktop computers, energizers were searching for a way to transfer files between two systems without having any physical device, and they come up with the internet, unfortunately at the first day of the internet, there was a problem, complex sets of commands had to be learned to use the internet.FTP, invented in early 1970, established a standard protocol for transferring files between systems.

In the first days of FTP, they introduced one of the key abilities of FTP, RFC or (Request for Comment), which we know by the name of downloading. At first, the RFC was based on a request that we send to the server, and in return, they give us replays with are the files that we needed. In 1971 the FTP protocol RFC114 was published. Over the years, the document revises with newer versions making changes to improve the FTP protocol. RFC 959 was published in 1985, which became the current standard specification. The RFC document is still being amended to date, with revisions to improve the security of FTP and adding support for newer technologies.

The purpose of making FTP was also to uploading webpages to servers for displaying on the internet, browsing, and downloading files from public pages all over the internet. With publishing this protocol, everyone was able to transfer large files between two computers with ease, which were too big to put in an email.

Fundamental FTP Terms:

Below we gathered some of the important roles of FTP.

Anonymous FTP: Various public servers allow anonymous login. Users can log in to servers without an account to download files. Uploading is not allowed for anonymous login. Please take note that your IP address is tracked even though it is an anonymous session. In short, it means you can see all the files with folder type view, you can touch anything, and you can grab everything, but you can’t put anything more than the administrator wants on the shelf.

Get: this resembles copying the website files to your computer; in modern terms, we also know it as ”download” this was also one of the purposes of making FTP.

Put: put means coping your file over the site or the webserver; now we know it by the name of upload. Uploading is restricted to authorized users only, which means you have to have an account with permission to edit the details on the website.

FTP Site: A hosting server that contains files for download and upload. To access the FTP site, you need to type in the address, which begins with FTP:// (instead of HTTP://).

FTP Connection Types: An important concept is that FTP connects using two TCP ports for all communications between the server and the user.

COMMAND:Port: This is the main TCP port created upon a session is connected. It is used for passing commands and replies. Port 21 (unsecured) or 990 (secured) are the default command ports used.

DATA: Each time when files or directories are transferred between server and client, a
random TCP data connection is established, and the data transfer commences over the connection. Once the data transfer is complete, the connection is closed. Subsequent data connections are established and terminated as required. Data connections are never left open.

FTP errors:

In this section, we’re going to talk and discuss the problems you might encounter when working with the FTP protocol.

How to run proftpd in debug mode:​

If you are having any issues logging in, uploading files, creating directories, etc.. you can run proftpd in debug mode to see what the proftpd server is doing and possibly find out why it’s generating the errors it is.

for doing this, you need to run this command:

/etc/init.d/proftpd stop
proftpd -n -d 20

after typing this command, it makes the proftp stop completely and then start it again in the console in the debug mode for you; remember that it is a little bit different on FreeBSD. In FreeBSD you’ll use “/usr/local/etc/RC.d/proftpd stop” to stop the proftp.

Then you can do all of that again to generate the error code; proftpd will dump out a lot of information about your problem for you; the errors you want usually happen right near the bottom of all of the output. Once you find what you need, press ctrl-c to quit the daemon. DA should automatically start proftpd up again in normal mode within a minute, or just start with the same command as above, but with “start” instead of “stop.

Showing hidden files through FTP:

for seeing the hidden files within the FTP, you have to edit your /etc/proftpd.conf.
in this section, add the following code:

ListOptions -a

save the edit, exit from it, and restart proftpd.

Updating or installing FTP service:

the simplest way and also the easiest to update or install ProFTPD is with custom build:

cd /usr/local/directadmin/custombuild
./build update
./build set ftpd proftpd
./build proftpd

also, for PureFTPD you can try this one:

cd /usr/local/directadmin/custombuild
./build update
./build set ftpd pureftpd
./build pureftpd

delete all remote tar.gz FTP files in a directory:

the script that we put below here will delete all .tar.X files in a remote directory. to changing the effect which files are removed, change the grep value:

#!/bin/sh

ftp_path=/remote/ftp/path
ftp_username=username
ftp_password=password
ftp_ip=remote.host.com
ftp_port=21

for i in `curl -s -l ftp://"$ftp_username":"$ftp_password"@$ftp_ip/$ftp_path/ | grep tar.gz`; do
{
       echo "deleting ${ftp_path}/$i";
       curl ftp://${ftp_ip}:${ftp_port}/${ftp_path}/${i} -u "${ftp_username}:${ftp_password}" -O --quote "DELE ${ftp_path}/${i}"
};
done;