There are two FTP connection methods: Port, active connection, PASV, and passive connection. The specific differences between the two will not be discussed. There are a lot of online materials.
We adopt PASV passive mode on the client.
First, we configure the Linux system firewall iptables (the firewall must be configured, otherwise the connection will not be reported 227 entering passive mode (150,235,145, 19). Error)
1. Edit the/etc/sysconfig/iptables-config file and add the following two lines:
IPTABLES_MODULES="ip_conntrack_ftp"IPTABLES_MODULES="ip_nat_ftp"
Please note that the positional relationship between the two rows should not be reversed. If you put "ip_nat_ftp" in front, it cannot be loaded. If your FTP service is a route or firewall (this module is required for Intranet ing ). The above is equivalent to running the modprobe command to load the "ip_nat_ftp" and "ip_conntrack_ftp" modules before loading iptables.
2. Add the following two lines to the iptables file:
[[email protected] ~]# vi /etc/sysconfig/iptables-A -INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT-A -INPUT -p tcp -m state --state NEW -m tcp --sport 21 -j ACCEPT-A -INPUT -P tcp --dport 20 -j ACCEPT
3. Check whether the following lines exist in the iptables file (default). If not, add them;
-A -INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Now we start to configure vsftp
Install vsftpd
1. Run the following command as the administrator (Root) (YUM installs vsftp)
yum install vsftpd
2. Set vsftpd FTP service to start upon startup
chkconfig vsftpd on
3. Start the vsftpd service
service vsftpd start
Manage vsftpd commands:
Stop vsftpd: Service vsftpd stop
Restart vsftpd: Service vsftpd restart
Configure the vsftpd Server
The default configuration file is/etc/vsftpd. conf. You can open it in a text editor.
vi /etc/vsftpd/vsftpd.conf
Add an FTP user
The following describes how to add a user and set the root directory to/home/wwwroot/user. This user is prohibited from logging on to SSH and is restricted from accessing other directories.
1. Modify/etc/vsftpd. conf.
Set the following three lines
#chroot_list_enable=YES# (default follows)#chroot_list_file=/etc/vsftpd.chroot_list
Change
chroot_list_enable=YES# (default follows)chroot_list_file=/etc/vsftpd/chroot_list
Modify the following parameters
Anonymous_enable = No // disable anonymous user login local_enable = Yes // enable local user login userlist_enable = No userlist_deny = Yes
Disable userlist_file =/etc/vsftpd. user_list. If userlist_deny = yes above,/etc/vsftpd. user_list cannot be logged on.
3. Add the user ftpuser and point to the/home/wwwroot/ftpuser directory. disable SSH access.
useradd -d /home/wwwroot/user -g ftp -s /sbin/nologin user
4. Set the User Password
passwd ftpuser
5. edit the file chroot_list: (used to prohibit access to the upper-level directory of the user's root directory)
vi /etc/vsftpd/chroot_list
-
Peter
-
-
-
John
6. Restart vsftpd.
service vsftpd restart
For detailed parameter settings, see http://vsftpd.beasts.org/vsftpd_conf.html
Vsftp environment setup and iptables settings