FTP file server deployment

The following steps take the deployment in the Ubuntu system as an example

1. Install vsftpd software

In the Linux system, you can use the package manager to install the vsftpd software.

sudo apt-get install vsftpd

2. Configure vsftpd software

After installing the vsftpd software, it needs to be configured. In Ubuntu systems, the configuration file is located at /etc/vsftpd.conf. The configuration file can be opened with the following command:

sudo nano /etc/vsftpd.conf

In the configuration file, you can set many options, such as setting the port used by the FTP server, whether to allow anonymous access, and so on. Here, we only cover some of the most basic settings.

2.1 Set FTP user

Add the following lines to the configuration file to set the default login username and password for the FTP server:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO
pasv_enable=Yes
pasv_min_port=40000
pasv_max_port=50000
userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO

Among them, the userlist_file option specifies a user list file, which is used to store the login user names of FTP users. A user list file can be created with the following command:

sudo touch /etc/vsftpd.user_list

Then, you can add an FTP user (for example, the username is ftpuser) with the following command:

sudo sh -c 'echo "ftpuser" >> /etc/vsftpd.user_list'
sudo useradd -m ftpuser -s /bin/bash
sudo passwd ftpuser

2.2 Set FTP root directory

Add the following lines to the configuration file to set the FTP root directory:

local_root=/home/ftpuser

Where, /home/ftpuser can be replaced with any directory you want as FTP root directory.

2.3 Setting up the firewall

If a firewall is enabled on your Linux system, you need to open the port used by the FTP server (21 by default) in the firewall. Taking the Ubuntu system as an example, you can use the following command to open the FTP port:

sudo ufw allow ftp

3. Start the FTP server

Once the configuration is complete, the FTP server can be started with the following command:

sudo service vsftpd start

Your FTP server is now ready to use. You can use any FTP client (such as FileZilla) to connect to your FTP server and log in with your FTP user's login credentials.

Guess you like

Origin blog.csdn.net/weixin_47450720/article/details/129416155
Recommended