Home  >  Article  >  php教程  >  Set up an FTP server in Linux

Set up an FTP server in Linux

高洛峰
高洛峰Original
2016-12-20 09:33:461274browse

Set up an ftp server in Linux for two working groups to store files. Disable anonymity. The first team uses the ftp account: ftp1, and the working directory is: /var/ftp/ftp1; the second team uses ftp2, and the working directory is: /var/ftp/ftp2.

 The two groups cannot access each other’s files, and users need to be restricted from leaving their working directories.

【Implementation steps】

1. Check the installation of vsftpd server

After entering the terminal as root (if you enter the terminal with other accounts, you can use su root to enter the password and enter root mode). After that, enter the following command in the terminal command window. Verification: # rpm –qa | grep vsftpd. If the result displays "vsftpd-1.1.3-8", it means that the vsftpd server has been installed on the system. If there is no reply, it means it is not installed in the system.

Set up an FTP server in Linux

The system CD of version 2.rhel contains the vsftpd installation package, so the next step is to mount the system CD to /media for easy retrieval.

Set up an FTP server in Linux

3. The above screenshot shows that the vsftpd server is not installed in this system, so use the rpm command to install it.

The command to install vsftpd in the terminal command window: #rpm -ivh vsftpd-1.1.3-8.i386.rpm.

(1) First mount the optical drive, there is rpm in the /mnt/cdrom/Server directory, rpm -ivh vsftpd*

Set up an FTP server in Linux

Set up an FTP server in Linux

4. Create a user

(1) First start the service

Set up an FTP server in Linux

(2) Create two users

Set up an FTP server in Linux

5.vsftpd configuration

After installation, there will be three configuration files in the /etc/vsftpd/ path.

vsftpd.conf: Main configuration file

ftpusers: Specify which users cannot access the FTP server. The users here include some important users including root.

user_list: Whether the specified user can access the ftp server, determine whether the user in the configuration can access the userlist_deny configuration in the vsftpd.conf file, userlist_enable=YES, userlist_deny=YES, userlist_file=/etc/vsftpd/user_list This Three configurations allow users in the file to access FTP.

(1) View the default configuration of the main configuration file:
(Use: cat /etc/vsftpd/vsftpd.conf | grep -v '^#';)

Set up an FTP server in Linux

(2) Modify the configuration file:

After logging in to ftp, you will find that the user can access other directories and has the permissions of the mpsp group. This is not allowed. We need to control the user's access scope to his home directory. The method is as follows:

a. vi /etc/vsftpd/vsftpd.conf Enter the ftp configuration file directory and edit this file,

Set up an FTP server in Linux

b.

Find #chroot_list_enable=YES, delete the # sign in front, which means it is enabled This restricted function;

Find chroot_list_file: chroot_list_file=/etc/vsftpd/chroot_list, delete the # sign in front, indicating that this restricted function is enabled; add chroot_local_use=NO

(press i after entering the edit box to start editing)

Set up an FTP server in Linux

c. After entering the configuration file, add the following three lines at the end:

① userlist_enable=YES

                                                                 .                                        

d. Ban anonymous users Login

Set up an FTP server in Linux

(After editing, press esc and use ":wq" to save and exit)


e. Edit some files

① Find the vsftpd.chroot_list file in the etc directory and enter the editing state

Add what you want Restricted user names, one user per line, such as ftp2

Set up an FTP server in Linux

(After editing, press esc and use ":wq" to save and exit)

② Enter the vsftpd directory, find vsftpd.user_list, type ftp11, which means ftp11 is allowed Log in to the ftp server

Set up an FTP server in Linux

(After editing, press esc and use ":wq" to save and exit)

Then on this machine, through the console, use ftp1 to access the system through ftp, the user successfully logged in, and successfully Are restricted to their own home directory and cannot access other directories.

Create 2 users, ftp1 and ftp2 in this order. P t View FTP status seastatus -b | GREP FTP:

Then enter:

Set up an FTP server in Linux

Turn off the firewall:

Set up an FTP server in Linux

The following steps are the mutual ping through the host and virtual machine:

Set up an FTP server in Linux

Set up an FTP server in Linux

Set up an FTP server in Linux

Set up an FTP server in Linux

Final result:

Set up an FTP server in Linux

Set up an FTP server in Linux


For more articles related to building an FTP server in Linux, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Linux ftp command usageNext article:Linux ftp command usage