CentOS 7 install vsftpd steps

1、 Install vsftpd components#

[ root@localhost ~]# yum -y install vsftpd

2、 Add a ftp user#

This user is used to log in to the ftp server.

[ root@localhost ~]# useradd ftpuser

After creating such a user, you can use this to log in. Remember to use ordinary login instead of anonymous. The default path after login is /home/ftpuser.

3、 Add password to ftp user#

[ root@localhost ~]# passwd ftpuser

Change the password after entering the password twice.

4、 The firewall opens port 21#

Because the default port of ftp is 21, and centos is not opened by default.

The firewall in centos7 has been changed to firewall. Using iptables has no effect. The method of opening ports is as follows:

firewall-cmd --zone=public --add-port=80/tcp --permanent

Return success as success.

Command meaning:

[ root@localhost ~]# firewall-cmd --zone=public --add-port=21/tcp --permanent

[ root@localhost ~]# firewall-cmd --reload

View open ports

[ root@localhost ~]# firewall-cmd --list-ports

5、 Modify selinux#

The external network can be accessed, but it is found that the directory cannot be returned (using the active mode of ftp, the passive mode is still not accessible), nor can it be uploaded, because selinux is causing trouble.

Modify selinux:

Execute the following command to view the status:

[ root@localhost ~]# getsebool -a | grep ftp

PS: Mine is modified and may be different from yours.

Execute the above command, and then return the result to see that both lines are off, which means that the external network access is not enabled

[ root@localhost ~]# setsebool -P allow_ftpd_full_access on

[ root@localhost ~]# setsebool -P tftp_home_dir on

Tested with FileZilla and found that the login was successful, but the directory could not be read. Let's change the transmission mode.

Active and passive mode modification of FileZilla:

Menu: Edit → Settings

6、 Turn off anonymous access#

[ root@localhost ~]# vi /etc/vsftpd/vsftpd.conf

Modify the /etc/vsftpd/vsftpd.conf file:

Save: wq, then press Enter to exit.

[ root@localhost ~]# service vsftpd restart

7、 Turn on passive mode#

It is enabled by default, but to specify a port range, open the vsftpd.conf file and add

pasv_min_port=30000

pasv_max_port=30999

Indicates that the port range is 30000~30999, this can be changed at will. After the change, restart vsftpd.

[ root@localhost ~]# vi /etc/vsftpd/vsftpd.conf

[ root@localhost ~]# service vsftpd restart

Since this port range is specified, the firewall also opens the corresponding port.

[ root@localhost ~]# firewall-cmd --zone=public --add-port=30000-30999/tcp --permanent
[ root@localhost ~]# firewall-cmd --reload

View:

[ root@localhost ~]# firewall-cmd --list-ports
Found that there are 30000-30999/tcp and it is done.

8、 Set boot to start vsftpd ftp service#

[ root@localhost ~]# chkconfig vsftpd on

9、 test#

a. FileZilla

Change FileZilla's FTP transfer mode to passive mode, then connect and find that you can go in.

b. Browser##

Input in the address bar: ftp://server address

Enter your account and password in the pop-up box that follows.

c. Java program

To create a program, ftp needs to rely on the commons-net-3.3.jar package

import java.io.File;import java.io.FileInputStream;import java.io.IOException;import org.apache.commons.net.ftp.FTP;import org.apache.commons.net.ftp.FTPClient;publicclassTestFTP{publicstaticvoidmain(String[] args) throws Exception, IOException {		FTPClient ftpClient =newFTPClient();		ftpClient.connect("192.168.195.138");		ftpClient.login("ftpuser","123456");		FileInputStream inputStream =newFileInputStream(newFile("E:\\taotao\\21.jpg"));//Specify upload directory//ftpClient.changeWorkingDirectory("/home/ftpuser/images/");		ftpClient.setFileType(FTP.BINARY_FILE_TYPE);		ftpClient.storeFile("123.jpg",inputStream);		inputStream.close();if(ftpClient.logout()){			System.out.println("success!");}else{			System.out.println("failure!");}}}

After the console prints successfully, check our server and you will find the picture 123.jpg.

END

Recommended Posts

CentOS 7 install vsftpd steps
CentOS 6.8 method steps to install vsftpd
1.5 Install Centos7
Linux CentOS 7 install JDK detailed steps
Centos6 install Python2.7.13
Centos7.3 install nginx
CentOS7.2 install Mysql5.7.13
CentOS install Redmine
Centos7 install Python 3.6.
CentOS7 install MySQL
Centos7 install protobuf
CentOS 7 install Docker
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Centos7 install Python2.7
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install mysql
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
CentOS6 install mist.io
Centos7 install Docker
CentOS7 install mysql
centOs install rabbitMQ
CentOS 7 install MySQL 5.6
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos7 install docker18
Centos install Python3
centos7 install docker
CentOS install jdk
centos7 install nginx-rtmp
CentOS8 install MySQL8.0
Centos6.3 install KVM
CentOS install PostgreSQL 9.1
CentOS7 install mysql8
CentOS 7 install Java 1.8
CentOS8 install fastdfs6.06
CentOS 7 install Gitlab
Centos 7 install PostgreSQL
CentOS7 install MySQL8
CentOS 7 install Java 1.8
CentOS 6 install Docker
centos 6.5 install zabbix 4.4
Centos8 install Docker
CentOS6.8 install python2.7
CentOS install nodejs 8
CentOS6.5 install GNS3
centos 7.5 install mysql5.7.17
Centos7 install MySQL8.0-manual
CentOS7 install Kubernetes 1.16.3
VirtualBox install centos7
centos7 install lamp