Build an FTP server in Linux and an ftp server in linux
Introduction
This chapter describes how to set up an FTP server in Linux. The key point to be mastered is the rational configuration of the configuration file.
Knowledge Point
- The FTP used in linux is vsftp
- FTP can be accessed in three ways:
Install FTP
Install with YUM
yum -y install vsftpd
File Configuration
After installation, there will be three configuration files in the/etc/vsftpd/path.
Vsftpd. conf: Main configuration file
Ftpusers: specifies which users cannot access the FTP server. Important users, including the root user, are listed here.
User_list: Specifies whether the user can access the ftp server through vsftpd. the configuration of userlist_deny In the conf file determines whether users in the configuration can access it. userlist_enable = YES, userlist_deny = YES, userlist_file =/etc/vsftpd/user_list these three configurations allow users in the file to access FTP.
View the default configuration of the main configuration file
cat /etc/vsftpd/vsftpd.conf |grep -v '^#';
Anonymous_enable = YES # Allow Anonymous Users
Local_enable = YES # Allow Logon using a local user account
Write_enable = YES # allow ftp users to write data
Connect_from_port_20 = YES # transmit data through Port 20
Other parameters include:
Ftpd_banner = welcome to ftp service: sets the welcome information after the server connection idle_session_timeout = 60: sets the control connection established after the remote client connection, when no operation is performed, data_connection_timeout = 120 is interrupted (in seconds, set the idle data interruption time accept_timeout = 60 set the time after which connect_timeout is automatically Established = 60 set the maximum activation time of the data connection, and how long is the disconnection, which is used by others; max_clients = 200 indicates the total number of concurrent client connections on the server is 200max_per_ip = 3 indicates the maximum number of connections on each client is 3local_max_rate = 50000 (50 kbytes/sec) maximum Transmission rate limit for Local Users anon_max_rate = 30000 maximum transmission rate limit for anonymous users pasv_min_port = port pasv-max-prot = port number defines the maximum and minimum ports, 0 represents any port; specify the port for the client connection; listen_address = set the IP address for the ftp service to listen to; which address can the client use to connect; listen_port = set the port number for FTP operation, the default value is 21local_root = path. All users can log on to the system. The main directory of the Logon account is defined. If this parameter is not specified, each user enters the home directory of the individual user; chroot_local_user = yes/no whether to lock the home Directory (all) of the user of the local system account. After locking, the user can only access the home directory/home/user of the user;
Chroot_list_enable = yes/no enable does not lock the user's list in the main directory. chroot_list_file =/etc/vsftpd/chroot_list specifies the list file userlist_enable = YES/NO whether to load the user list file; userlist_deny = YES indicates that the user loaded above is allowed to log on. userlist_file =/etc/vsftpd/user_list specifies the list file
Create an FTP connection user
Create user ftpuseruseradd ftpusr set user can only ftp login usermod-s/usr/sbin/nologin ftpuser Set User Password passwd ftpusr
The default home directory of the user is under/home, and the current user can only access the home directory.
Modify the user's home directory bit/mnt
usermod -d /mnt ftpuser
Start FTP service
service vsftpd start
Test
Create a test file in the/mnt directory
touch /mnt/test
Connect to ftp
Solve the Problem of normal FTP login failure
Linux has a security mechanism by default. You can use sftp to connect to the ftp server without using the common ftp port 21. In this case, selinux needs to be disabled. to modify the configuration file, restart the server.
vim /etc/sysconfig/selinux
Change to selinux = disabled
Do not restart the server:
setenforce 0
Setenforce 1: Set SELinux to enforcing Mode
Setenforce 0: Set SELinux to permissive Mode
Summary
Some other configuration methods are not listed here. If you are interested, you can study them in depth.
|
Note:
Author: pursuer. chen
Blog: http://www.cnblogs.com/chenmh
All essays on this site are original. You are welcome to repost them. However, you must indicate the source of the article and clearly give the link at the beginning of the article.
Welcome to discussion |