Setup and configuration of centos FTP Server

Source: Internet
Author: User

Yum install vsftpd

2. Start/restart/shut down the vsftpd Server
[Root @ localhost FTP] #/sbin/service vsftpd restart
Shutting down vsftpd: [OK]
Starting vsftpd For vsftpd: [OK]
OK indicates that the restart is successful.
Change restart to start/stop for Start and Stop respectively.
If the source code is installed, find the start. SH and shutdown. Sh files in the installation folder and execute them.

3. files and folders related to the vsftpd Server
The configuration file of the vsftpd server is/etc/vsftpd. conf.

The root directory of the vsftpd server, that is, the home directory of the FTP server:
Pub at/var/ftp
If you want to modify the path of the server directory, you only need to modify/var/FTP elsewhere.

4. Add an FTP Local User
Some FTP servers require the user name and password to log on, because ftp users and permissions are set.
FTP users generally cannot log on to the system, but can only access the FTP server's own directory, which is for security. such a user is called a virtual user. in fact, it is not a real virtual user, but cannot log on to the shell, and cannot log on to the system.

/Usr/sbin/adduser-D/opt/test_ftp-g ftp-S/sbin/nologin Test
This command indicates:
Use the command (adduser) to add the test user. You cannot log on to the system (-S/sbin/nologin). Your own folder is in (-D/opt/test_ftp )), group FTP (-g ftp)
Then you need to set the passwd Test password for it.
In this way, an FTP user is added. The following example can help you access the FTP server.

[Root @ localhost FTP] # ftp
Ftp> open 192.168.0.33
Connected to 192.168.0.33 (192.168.0.33 ).
220 (vsftpd 2.0.5)
Name (192.168.0.33: GXL): Test
331 please specify the password.
Password:
230 login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
Ftp> quit
221 goodbye.

In Windows, you only need to enter ftp: // 192.168.0.33 in the browser to enter the FTP server, right-click to log on, and enter the user name and password to log on to your directory.
Of course, to ensure that you can read and write your own directories, you must set it in the configuration file vsftpd. conf to read and write.
Local_enable = Yes
Write_enable = Yes
Local_umask = 022

5. upload and download anonymously
Modify the configuration file to vsftpd. conf. Make sure there are the following lines. You can add them without yourself.
Anonymous_enable = Yes
Anon_upload_enable = Yes
Anon_mkdir_write_enable = Yes
Anon_umask = 022

Then you can create a new folder and change its permissions to fully open. Any user can log on to the folder and upload and download files:
Mkdir/var/FTP/guest
Chmod 777/var/FTP/guest

6. Customize the welcome information for accessing the FTP server
Set in the vsftpd. conf file:
Dirmessage_enable = Yes
Then go to the user directory and create a. Message file. Enter the welcome information (Welcome to gxlinux's FTP is written here !) :
[Root @ localhost test_ftp] # ftp 192.168.0.33
Connected to 192.168.0.33 (192.168.0.33 ).
220 (vsftpd 2.0.5)
Name (192.168.0.33: GXL): Test
331 please specify the password.
Password:
230-Welcome to gxlinux's FTP!
230 login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

7. Implement Virtual paths
Mount a directory to an FTP server for your use. This is called a virtual path.
For example, mount the GXL user directory to the FTP server for use by FTP Server users. Run the following command:
[Root @ localhost opt] # Mount -- bind/home/GXL/var/FTP/pub # Use the mount command
[Root @ localhost opt] # ls/var/FTP/pub
Lumaqq screenshot.png Desktop

8. Enable the log function of vsftpd.
Add the following line to the vsftpd. conf file. Generally, this line exists in the file. You only need to remove the annotator #. If not, add or modify the line:
Xferlog_file =/var/log/vsftpd. Log

9. Limit the number of links and the maximum number of links per IP Address
Modify the configuration file. For example, vsftp supports a maximum of 100 connections. Each IP address supports five links:
Max_client = 100
Max_per = 5

10. limit transmission speed
Modify the configuration file, for example, allow anonymous users and users on vsftd (I .e. virtual users) to download at 80 KB = 1024*80 = 81920
Anon_max_rate = 81920
Local_max_rate = 81920

11. restrict users (generally virtual users) to their own directories
Modify the configuration file so that users can only access their own directories:
Chroot_local_user = Yes
If you only want some users to access their own directories, and other users do not have this restriction, you need to go to the chroot_list file (this file is usually in/etc/vsftpd) add this user.
Edit this file. For example, if you add a user named test to this file, you can write it. Generally, a user occupies a row.
[Root @ localhost vsftpd] # Cat chroot_list
Test

12. bind an IP address to vsftpd
Sometimes it is necessary to restrict some IP addresses to access the server and only allow some IP addresses to access the server. For example, if only 192.168.0.33 is allowed to access the FTP, the configuration file is also modified:
Listen_address = 192.168.0.33

Configure vsftpd. conf
Anonymous_enable = No # disable Anonymity
Local_enable = yes # Allow Local Login
Write_enable = yes # Allow write. Required for upload
Local_umask = 027 # Set the object upload permission to 777-local_umask.
Anon_upload_enable = yes # Allow Upload by virtual users and anonymous users
Anon_other_write_enable = yes # Allow virtual users and anonymous users to modify file names and delete files
Dirmessage_enable = Yes
Xferlog_enable = yes # Enable Logging
Connect_from_port_20 = Yes
Xferlog_file =/var/log/vsftpd. log # log storage location
Xferlog_std_format = yes # standard log format
Idle_session_timeout = 600 # idle connection timeout
Data _ connection_timeout = 120
Ftpd_banner = welcome to chinarise FTP service # Welcome Information
Guest_enable = yes # Allow virtual users
Guest_username = vsftpdguest # SYSTEM account used by the virtual user
Virtual_use_local_privs = yes # virtual users have local system Permissions

Chroot_local_user = No
Chroot_list_enable = Yes
# The above two lines are restricted to virtual users under their directories, and cannot access other directories, or directly use
Chroot_local_user = Yes

Listen = yes # listener/Passive Mode
Listen_port = 21 # listening port

Chroot_list_file =/etc/vsftpd. chroot_list # Save the virtual user name list in the file/etc/vsftpd. chroot_list
User_config_dir =/etc/vsftpd/vsftpd_user_conf # more detailed cultivation of each virtual user name is stored in/etc/vsftpd/vsftpd_user_conf

Other virtual user settings

Write the names of virtual users allowed to log on to the/etc/vsftpd. chroot_list file. Each line has one
Create a file named after the virtual user name in the/etc/vsftpd/vsftpd_user_conf folder,
Write: local_root =/var/FTP/subdirectory name
Create a directory under/var/FTP.

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.