Enable ftp for CentOS
1. after the vsftpd component is installed,/etc/vsftpd is installed. conf file, used for configuration, and a new ftp user and ftp group, pointing to the home directory as/var/ftp. The default value is nologin (cannot log on to the system )?yum -y
install
vsftpd
You can run the following command to view the user
?
cat
/etc/passwd
The ftp service is not started by default. Run the following command to start
?
service vsftpd start
2. Install the ftp client component (used to verify whether vsftpd is used )?
yum -y
install
ftp
Run the command to try to log on?
ftp
localhost
Enter the ftp user name and password (because anonymous access is allowed by default)
If the logon succeeds, the ftp service is available.
However, the Internet cannot be accessed, so the configuration should be continued.
3. Cancel anonymous login
?
vi
/etc/vsftpd/vsftpd
.conf
Change anonymous_enable = YES in the first line to NO
Restart
?
service vsftpd restart
4. Create a new user (ftpuser is the user name and can be used as needed)
?
useradd
ftpuser
Change Password (twice)
?
passwd
ftpuser
After such a user is created, you can use this logon. Remember to use normal logon instead of anonymous logon. The default path after logon is/home/ftpuser.
5. Open Port 21
Because the default ftp port is 21, and centos is not enabled by default, You need to modify the iptables File
?
vi
/etc/sysconfig/iptables
On the line above, enter another line under 22-j ACCEPT, which is similar to that line, just replace 22 with 21, and then save: wq.
And restart iptables.
?
service iptables restart
The Internet can be accessed, but the directory cannot be returned or uploaded because selinux is an exception.
6. Modify selinux
?
getsebool -a |
grep
ftp
Run the preceding command, and then the returned result shows that both rows are off, indicating that Internet access is not enabled.
?
....
allow_ftpd_full_access off
....
....
ftp_home_dir off
You just need to turn all the above into on.
Run
?
setsebool -P allow_ftpd_full_access 1
setsebool -P ftp_home_dir off 1
Restart vsftpd?
service vsftpd restart
This should be okay (if it still doesn't work, check if the ftp client tool is used for passive mode access. If you prompt Entering Passive mode, it indicates passive mode, the default mode is unavailable because the ftp passive mode is blocked by iptables. The following describes how to enable it. If you are too lazy to enable it, check whether the ftp client has port mode options, or remove the passive mode option. If the client still does not work, check whether the firewall is enabled on the host computer on the client)
7. Enable passive Mode
It is enabled by default, but you must specify a port range to open the vsftpd. conf file, and add
Pasv_min_port = 30000
Pasvanderbilt max_port = 30999
Indicates the port range is 30000 ~ 30999. This can be changed at will.
Restart vsftpd.
Because the port range is specified, iptables needs to enable the range accordingly, so open the iptables file as above.
It is also in the top and bottom of the 21 line, the line is similar, just change 21 to 30000: 30999, then: wq save, restart iptables. This is done.