What is FTP and how it works
FTP server is a software used to transfer, upload and download data over the Internet and network. FTP stands for File Transfer Protocol, it is one of the oldest and the most popular method of file exchange. Once the system is working you don’t need to perform many operations to send big or numerous files to another server all over the world. Besides in case of Internet disconnection while you were uploading (or downloading) a file the process will be resumed once the connection is reestablished. Setup FTP server is available for Windows and for Linux as well. The configuration of ftp for Linux distributions differ a little but you still can pick what you need: setting up Ubuntu FTP Server, Fedora or Suse. But speed is the one of disadvantages of FTP.
By default FTP server operates on port 21 using TCP. Port 20 performs data transfer. As a rule to connect to FTP server a username and a password are needed. Sometimes anonymous access is available. When you set up FTP server Ubuntu it can operate in passive and active modes. Which one is used depends on the settings of server and client’s firewalls.
Ubuntu FTP server installation
One of the most used and easy to maintain FTP server for Ubuntu is Pure-FTPd. To configure it you should know how to connect SSH to your server and how to insert commands into terminal.
apt-get update apt-get install pure-ftpd
Lets define which user will be used to start our FTP as. In my case NginX server works as www-data user and I will use this user for my FTP setup. We need NginX and FTP have the same permissions to read and write files.
First thing we should check ID of the user:
id www-data uid=33(www-data) gid=33(www-data) groups=33(www-data)
You can see that www-data has id 33 , keep in mind that minimal UID for Pure-FTP is 1000, so we should change this value. We nee to edit /etc/pure-ftpd/conf/MinUID and set desired UID. In my case it looks:
cat /etc/pure-ftpd/conf/MinUID 33
When we are done with settings for running as www-data lets create virtual user, you will be prompted to setup a password for the virtual user:
pure-pw useradd joe -u www-data -d /var/www/wp-lab.itsyndicate.org
Now we need to create user database:
ln -s /etc/pure-ftpd/pureftpd.passwd /etc/pureftpd.passwd
ln -s /etc/pure-ftpd/pureftpd.pdb /etc/pureftpd.pdb
ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/PureDB
Please be advices that in some cases you will need to enable Passive mode for your setup. This is a must have option when you are using AWS, because EC2 instance has internal IP address and you will have issues without this option. Following commands will enable Passive mode for us:
cd /etc/pure-ftpd/conf sudo bash -c 'echo "35000 36000" > PassivePortRange' sudo bash -c 'echo "<your-server-ip>" > ForcePassiveIP' sudo bash -c 'echo "yes" > DontResolve'
When everything is done, simply restart Pure-FTPd:
service pure-ftpd restart
FTP server security
To make FTP secure we will have to install TLS support:
apt-get install openssl
echo 2 > /etc/pure-ftpd/conf/TLS
Generate private key:
openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem
chmod 600 /etc/ssl/private/pure-ftpd.pem
service pure-ftpd restart
This is not the only method for file transfer. I prefer to use SFTP server on Ubuntu. In contrast to FTP server SFTP (Secure File Transfer Protocol) provides encrypted data exchange and it uses only one connection between a serves and a client. It eliminates problems with firewalls which occurred in FTP connection.
Thus getting to know all those details about FTP server will broaden your perspective but nevertheless selecting the right server for your business may be time-consuming. ITsyndicate can setup any FTP server Linux properly. Working with us you get understanding why this or that software is the best for your business, you’ll always know what a system administrator is doing and why.