How to Set Up an FTP Server on CentOS 7
![How to Set Up an FTP Server on CentOS 7](/static/img/files/linux.webp)
Setting up an FTP (File Transfer Protocol) server on CentOS 7 can be a valuable skill for anyone dealing with file management or website hosting. FTP allows for the easy and secure transfer of files between a server and a client. In this guide, we will walk you through the step-by-step process of setting up an FTP server on CentOS 7, ensuring a seamless file transfer experience.
Prerequisites:
Before diving into the installation process, make sure you have the following prerequisites:
- A CentOS 7 server with root access.
- A stable internet connection.
- Basic knowledge of using the Linux command line.
Step 1: Update System Packages
To begin, it's essential to ensure that your system is up-to-date. Open your terminal and run the following commands:
sudo yum update
This will update all the packages on your CentOS 7 system.
Step 2: Install vsftpd (Very Secure FTP Daemon)
The next step is to install the vsftpd package, which is a fast and secure FTP server for Unix-like systems. Execute the following command in your terminal:
sudo yum install vsftpd
Step 3: Start and Enable vsftpd Service
Once the installation is complete, start the vsftpd service and enable it to start at boot:
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
Step 4: Configure Firewall
To allow FTP traffic, you need to open the FTP port (default is 21) in your firewall. Use the following commands:
sudo firewall-cmd --permanent --add-port=21/tcp
sudo firewall-cmd --reload
Step 5: Create FTP User
Create a user account for FTP access. Replace 'ftpuser' with your desired username:
sudo adduser ftpuser
sudo passwd ftpuser
Step 6: Adjust SELinux Settings
To allow FTP to write to the user's home directory, set the SELinux boolean value:
sudo setsebool -P ftp_home_dir on
Step 7: Test FTP Connection
Now, use an FTP client like FileZilla to connect to your server. Enter the server's IP address, FTP username, and password. You should be able to establish a connection.
More Examples:
Limiting FTP Access to a Specific Directory:
Edit the vsftpd configuration file:
sudo nano /etc/vsftpd/vsftpd.conf
Add or modify the following line:
chroot_local_user=YES
Save the file and restart the vsftpd service:
sudo systemctl restart vsftpd
This restricts users to their home directory upon FTP login.
Enabling Passive Mode:
To enable passive mode, add the following lines to the vsftpd configuration file:
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40100
Save the file and restart the vsftpd service.
Related Searches and Questions asked:
That's it for this topic, Hope this article is useful. Thanks for Visiting us.