Enable FTP for centos

Source: Internet
Author: User
Tags default ftp port ftp client
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, default 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
Execute the command and 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.