Explain the process of installing and configuring the FTP server software vsftp in CentOS

Time:2020-10-23

Install vsftp

Copy code

The code is as follows:

yum -y install vsftpd

Create FTP log file path

Copy code

The code is as follows:

touch /var/log/vsftpd.log

Start configuration

Copy code

The code is as follows:

chkconfig –list vsftpd

If it is all off, set 0: off 1: off 2: off 3: off 4: off 5: off 6: off manually

Copy code

The code is as follows:

chkconfig –level 2345 vsftpd on

Start FTP service:

Copy code

The code is as follows:

service vsftpd start

To view FTP service status:

Copy code

The code is as follows:

service vsftpd status

Restart FTP service:

Copy code

The code is as follows:

service vsftpd restart

Shut down FTP service:

Copy code

The code is as follows:

service vsftpd stop

Edit profile

Copy code

The code is as follows:

vi /etc/vsftpd/vsftpd.conf
Copy code

The code is as follows:

anonymous_ Enable = no ා sets that anonymous access is not allowed
local_ Enable = yes ා set the local user can access. Note: if the virtual host user is used, all virtual users will not be able to access when the item is set to No.
chroot_ list_ Enable = yes ා prevents users from leaving the home directory
xferlog_ file=/var/log/ vsftpd.log #Set the service log saving path of vsftpd. Note that the file does not exist by default. You have to touch it manually
ascii_ upload_ Enable = yes ා allows uploading in ASCII mode
ascii_ download_ Enable = yes ා set the upload and download functions in ASCII mode.
pam_ service_ Name = vsftpd ා PAM authentication file name. PAM will be certified according to / etc / pam.d/vsftpd

The following are important CentOS FTP service configuration items for vsftpd virtual user support.

default vsftpd.conf You need to manually add the RHEL / CentOS FTP service configuration.

Copy code

The code is as follows:

guest_ Enable = yes ා set to enable virtual user function.
guest_ Username = FTP ා specifies the host user of the virtual user. -There are already built-in FTP users in RHEL / CentOS
user_ config_ dir=/etc/vsftpd/vuser_ Conf ා set the file storage path of RHEL / CentOS FTP service of virtual user personal vsftp. CentOS FTP service file for storing virtual user personality (configuration file name = virtual user name)

Create chroot list and add FTP users to it:

Copy code

The code is as follows:

touch /etc/vsftpd/chroot_list
echo ftp >> /etc/vsftpd/chroot_list

Installing Berkeley DB tools

Copy code

The code is as follows:

yum install db4 db4-utils

Create user password text, note that odd line is user name, even line is password

Copy code

The code is as follows:

vi /etc/vsftpd/vuser_passwd.txt
ftpuser1
ftppass1
ftpuser2
ftppass2

Generate DB file of virtual user authentication

Copy code

The code is as follows:

db_load -T -t hash -f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db

Edit the authentication file and comment out all configurations

Copy code

The code is as follows:

vi /etc/pam.d/vsftpd

Add the following two sentences

Copy code

The code is as follows:

auth required pam_userdb.so db=/etc/vsftpd/vuser_passwd
account required pam_userdb.so db=/etc/vsftpd/vuser_passwd

Create virtual user profile RHEL / CentOS FTP service file

Copy code

The code is as follows:

mkdir /etc/vsftpd/vuser_conf/
vi /etc/vsftpd/vuser_conf/ftpuser1

The contents are as follows:

Copy code

The code is as follows:

local_ Root = / opt / var / ftp1 ා the root directory of the virtual user (modified according to the actual situation)
write_ Enable = yes ා writable
anon_ Umask = 022 mask
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES

Open firewall port

Copy code

The code is as follows:

vi /etc/sysconfig/iptables

Add a line, the port number uses the default 21 port

Copy code

The code is as follows:

-A INPUT -p tcp -m state –state NEW -m tcp –dport 21 -j ACCEPT

Attach permissions to the directory and restart the vsftp service:

Copy code

The code is as follows:

mkdir /opt/var/ftp/ftpuser1
chmod 777 /opt/var/ftp/ftpuser1
service vsftpd restart