Centos FTP server erection and configuration tutorial

  
 

1. Install yum install vsftpd

2. Start/restart/close vsftpd server [root@localhost ftp]# /sbin/service vsftpd restartShutting down vsftpd: [ OK ]Starting vsftpd for vsftpd: [ OK ]OK means that the restart is successful. Start and close respectively change restart to start/stop. If it is source installation, 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 for the vsftpd server is: /etc/vsftpd/vsftpd.conf

The root directory of the vsftpd server, which is the home directory of the FTP server: In the /var/ftp pub if you want to modify the path of the server directory, then you only need to modify /var/ftp to other places

4. Add FTP local users Some FTP servers require a username and password. Login, because the FTP user and permissions are set. FTP users can't log in to the system. They can only enter the FTP server's own directory. This is for security. Such users are called virtual users. Actually it is not real. Virtual user, just can't log in to SHELL, no Ability to log in to the system.

/usr/sbin/adduser -d /opt/test_ftp -g ftp -s /sbin/nologin test This command means: add user with command (adduser), can't log in system (-s /sbin/nologin), your own folder is in (-d /opt/test_ftp), belongs to group ftp (-g ftp) and then you need to set password passwd test for it to add an FTP user. The following example can help you get into the FTP server.

[root@localhost ftp]# ftpftp> open 192.168.0.33Connected to 192.168.0.33 (192.168.0.33).220 (vsFTPd 2.0.5)Name ( 192.168.0.33:gxl): test331 Please specify the password.Password:230 Login successful.Remote system type is UNIX.Using binary mode to transfer files.ftp> quit221 Goodbye.

In windows, just browse Enter ftp://192.168.0.33 into the FTP server, then right click on the login, enter the user name and password to log in to your own directory. Of course you have to ensure that you can read and write your own directory, you must in the configuration file vsftpd.conf Set it up and read and write. local_enable=yeswrite_enable=yeslocal_uma Sk=022

5. Anonymous upload and download modify the configuration file to vsftpd.conf, determine the following lines, you can add it yourself. Anonymous_enable=yesanon_upload_enable=yesanon_mkdir_write_enable=yesanon_umask=022
< Then you can create a new folder, modify its permissions to be completely open, any user can log in to this folder and upload the downloaded file: mkdir /var/ftp/guestchmod 777 /var/ftp/guest

6. Customize the welcome message into the FTP server in the vsftpd.conf file: dirmessage_enable=yes then enter the user directory to create a .message file, enter the welcome message (I wrote here is Welcome to gxlinux’s FTP !):[root@localhost test_ftp]# ftp 192.168.0.33Connected to 192.168.0.33 (192.168.0.33).220 (vsFTPd 2.0.5)Name (192.168.0.33:gxl): test331 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. Implementing a virtual path to mount a directory to an FTP server for users to use, This is called a virtual path. For example, mount the gxl user's directory to the FTP server for users of the FTP server. Use the following command: [root@localhost opt]# mount –bind /home/gxl /var/Ftp/pub #Use the mount command [root@localhost opt]# ls /var/ftp/pubLumaQQ Screenshot.png Desktop

8. Open the log function of vsFTPd and add the following line to the vsftpd.conf file. In this case, there is this line in the file, just remove the previous comment symbol #, add it if not, or modify: xferlog_file=/var/log/vsftpd.log

9. Limit the number of links, And the maximum number of links per IP modification configuration file, for example, vsftp maximum support link number of 100, each IP can support 5 links: max_client=100max_per=5

10. Limit transmission speed modification configuration file For example, let anonymous users and users on vsftd (ie virtual users) download at 80KB=1024*80=81920 at the speed of anon_max_rate=81920local_max_rate=81920

11. Limit users (generally referred to as virtual users) In the home directory to modify the configuration file, so users can only access their own home directory: ch Root_local_user=yes If you only want some users to only access their own directories, other users do not make this limitation, then you need to add this user in the chroot_list file (this file is usually in /etc/vsftpd/). Edit this file For example, if you add the test user to this file, you can write it. In general, one user takes one line. [root@localhost vsftpd]# cat chroot_listtest

12. Bind an IP to vsFTPd sometimes restricts certain IP access servers, allowing only certain IP accesses. For example, only 192.168.0.33 is allowed to access this FTP. The configuration file is also modified: listen_address=192.168.0.33 configuration vsftpd.confanonymous_enable=NO #disallow anonymous local_enable=YES #Allow local login write_enable=YES #Allow write, if you need to upload, you must local_umask=027 #Set the permissions of the uploaded file to: 777-local_umaskanon_upload_enable=YES #Allow virtual users and anonymous users to upload anon_other_write_enable=YES #Allow virtual users and Anonymous user modify file name and delete file dirmessage_enable=YESxferlog_enable=YES #Open log record connect_from_port_20=YESxferl Og_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=120ftpd_banner=Welcome to ChinaRise FTP service #Welcome information guest_enable=yes #Allow virtual user guest_username=vsftpdguest #Virtual user system account virtual_use_local_privs=YES #Virtual user owns local system permissions

chroot_local_user=NOchroot_list_enable=YES#The above two lines restrict virtual users to their directories, cannot access other directories, or directly use chroot_local_user= YES

listen=yes #listening/passive mode listen_port=21 #listening port

chroot_list_file=/etc/vsftpd/vsftpd.chroot_list #Virtual user list is saved in the file /etc/vsftpd/vsftpd User_config_dir=/etc/vsftpd/vsftpd_user_conf in .chroot_list #More detailed cultivation of each virtual username is stored in /etc/vsftpd/vsftpd_user_conf

Virtual User Other Settings

in /etc Write the name of the virtual user allowed to log in in the /vsftpd/vsftpd.chroot_list file, one per line Create a file named after the virtual user username in the /etc/vsftpd/vsftpd_user_conf folder, write: local_root = /var/FTP/subdirectory name and create a corresponding directory under /var/FTP

Copyright © Windows knowledge All Rights Reserved