官术网_书友最值得收藏!

  • Linux:Powerful Server Administration
  • Uday R. Sawant Oliver Pelz Jonathan Hobson William Leemans
  • 475字
  • 2021-07-09 18:16:57

Installing the secure FTP server

In this recipe, we will learn how to install the File Transfer Protocol (FTP) server and configure it to use SSL encryption.

Getting ready

You will need access to a root account or an account with sudo privileges.

How to do it…

Follow these steps to install the secure FTP server:

  1. Install vsftpd with the following command:
    $ sudo apt-get update
    $ sudo apt-get install vsftpd
    
  2. After installation, we can configure vsftpd by editing /etc/vsftpd.conf.
  3. First create the SSL certificate for the FTP server:
    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
    
  4. Next, configure Vsftpd. Add or edit the following lines in vsftpd.conf:
    anonymous_enable=no
    local_enable=yes
    write_enable=yes
    chroot_local_user=yes
    Add the SSL certificate created in the previous step:
    rsa_cert_file=/etc/ssl/private/vsftpd.pem
    rsa_private_key_file=/etc/ssl/private/vsftpd.pem
    ssl_enable=yes
    ssl_ciphers=high
    force_local_data_ssl=yes
    force_local_logins_ssl=yes
  5. Save and exit the configuration file.
  6. Restart the Vsftpd server:
    $ sudo service vsftpd restart
    
  7. Now you can use any FTP client that supports the SFTP protocol to connect to your FTP server. The following is the configuration screen for SFTP client FileZilla:

How it works…

FTP is an insecure protocol and you should avoid using it, especially in a production environment. Limit use of FTP to downloads only and use more secure methods, such as SCP, to upload and transfer files on servers. If you have to use FTP, make sure that you have disabled anonymous access and enable SFTP to secure your data and login credentials.

In this recipe, we have installed Vsftpd, which is a default FTP package in the Ubuntu repository. Vsftpd stands for very secure FTP daemon, and it is designed to protect against possible FTP vulnerabilities. It supports both FTP and SFTP protocols.

As Vsftpd is available in the Ubuntu package repository, installation is very simple, using only a single command. After Vsftpd installed, we created an SSL certificate to be used with an FTP server. With this configuration, we will be using the SFTP protocol, which is more secure than FTP. You can find more details about SSL certificates in Chapter 3, Working with Web Servers.

Under the Vsftpd configuration, we have modified some settings to disable anonymous logins, allowed local users to use FTP, enabled write access, and used chroot for local users. Next, we have set a path for previously generated SSL certificates and enabled the use of SSL. Additionally, you can force the use of TLS over SSL by adding the following lines to the configuration file:

ssl_tlsv1=yes
ssl_sslv2=no
ssl_sslv3=no

There's more…

This recipe covers FTP as a simple and easy-to-use tool for network storage. FTP is inherently insecure and you must avoid its use in a production environment. Server deployments can easily be automated with simple Git hooks or the sophisticated integration of continuous deployment tools such Chef, Puppet, or Ansible.

See also

主站蜘蛛池模板: 万安县| 凤山县| 尼木县| 榕江县| 广宗县| 闽清县| 禹州市| 思南县| 革吉县| 高陵县| 洛扎县| 汉阴县| 错那县| 东兴市| 洞口县| 大余县| 金门县| 靖宇县| 太白县| 宜昌市| 城口县| 太和县| 德化县| 南木林县| 肃宁县| 建始县| 库伦旗| 宝应县| 珠海市| 涟水县| 南康市| 临沧市| 光泽县| 开江县| 宜君县| 抚顺市| 南京市| 封丘县| 左贡县| 石门县| 广宁县|