Deploy FTP server under ubuntu

A brief introduction to FTP##

FTP is one of the protocols in the TCP/IP protocol suite, that is, the file transfer protocol. It works on the fourth layer (application layer) of the TCP model. It uses TCP transmission to use interactive access and allows the client to specify file types and formats. Generally It is ASCII code and text format.

FTP connection mode##

FTP has two ports, one port is used as a control connection port, port 21, which is used to send commands to the server and wait for the server to respond; two ports are data transmission ports, the port number is 20, used to establish data Transmission channel; so there are two FTP connection modes, active and passive, namely PORT and PASV, which are relative to the server, similar to the active and passive of zabbix.

PORT mode###

The active mode FTP client establishes a connection channel between its own high port and the TCP port 21 of the FTP server, and sends commands through this channel. When the client needs to receive data, it sends a PORT command on this channel to tell the server that the client uses What port receives the data, so that after the server receives the client's port information, it connects through its 20 port and the client's designated random high port, and the data link is established.

PASV mode###

Passive mode is when the client sends a data request, the server will also send a message to the client, telling the client that the server has opened a high port in its local, let the client to connect, when the client receives the server's After the information, it connects to the high random port of the server, and the data link is established.

the difference###

The two modes are mainly different in data link establishment. The active mode is that the client opens a high port locally and waits for the server to establish a connection, and the passive mode is that the server opens a high port and waits for the client to establish a data connection.

Knowing this is almost the same for understanding FTP. Now let’s introduce how to build active and passive FTP under ubuntu.

Build##

Install FTP

1 sudo apt install vsftpd

Create FTP Follow Directory and User###

12345 $ sudo mkdir -p /data/storage$ sudo adduser www$ sudo adduser ftpadmin --ingroup www$ sudo chown -R www.www /data/storage$ sudo chmod g+w /data/storage

Let me talk about the role of these two users created here: www user is our web user, all applications are controlled by this user; ftpadmin is FTP user

Configure Active Mode###

1 2 3 4 5 6 7 8 910111213141516171819202122 listen=NOlisten_ipv6=YESanonymous_enable=NOlocal_enable=YESdirmessage_enable=YESuse_localtime=YESxferlog_enable=YESconnect_from_port_20=YES #Whether to use port 20 for data transmission in active mode xferlog_file=/var/log/vsftpd/emptam_dir_std_runformat=YES vsftpdrsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pemrsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.keyssl_enable=NOchroot_local_user=YESallow_writeable_chroot=0YESfilewrite_enable=/umask=0666local #Active mode on

After the configuration is complete, restart vsftpd, and the active mode is turned on

Passive mode configuration###

1 2 3 4 5 6 7 8 910111213141516171819202122232425 listen=NOlisten_ipv6=YESanonymous_enable=NOlocal_enable=YESdirmessage_enable=YESuse_localtime=YESxferlog_enable=YESxferlog_file=/var/log/vsftpd.logxferlog_std_format=YESanonymous_enable=NOlocal_enable=YESdirmessage_enable=YESuse_localtime=YESxferlog_enable=YESxferlog_file=/var/log/vsftpd.logxferlog_std_format=YESsecure_chroot_dir=/var/etc-slakes-certam/ .pemrsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.keyssl_enable=NOchroot_local_user=YESallow_writeable_chroot=YESwrite_enable=YESlocal_root=/data/storagelocal_umask=0file_open_YES=0666pasv_enable=YESsvpassive_min_ports_min_passive_max_ports_min_pasv_enable=YES250 Security check in mode

test###

Use filezilla or a browser to directly access the ftp://ftp address, we use curl here to upload and download

1 ) Create multiple files

1 for i in seq 1 100;do echo "num: i" > upload_i.log;done

2 ) Upload multiple files

1 for i in seq 1 100;do curl -u ftpadmin:Tccm2008 -T upload_$i.log ftp://10.0.3.111 ;done

3 ) Download multiple files

1 for i in seq 1 100;do curl ftp://10.0.3.111/upload_i.log -u ftpadmin:Tccm2008 -o download_i.log ;done

Recommended Posts

Deploy FTP server under ubuntu
Deploy the mail system under Ubuntu 19.10
Install and deploy Gerrit under Ubuntu
Build an FTP server under centos7
Ubuntu install ftp server and possible problems
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Deploy springboot project through docker under Ubuntu
How to quickly deploy docker on ubuntu server
Install apache+PHP under Ubuntu
Install node.js under Ubuntu
Deploy GitBook under CentOS7
ubuntu16.04 deploy GPU environment
Install python3.6 under Ubuntu 16.04
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Python MySQLd under Ubuntu
Start working under ubuntu
[python] python2 and python3 under ubuntu
Use iptables under ubuntu
2018-09-11 Install arduino under Ubuntu
LNMP installation under Ubuntu
Network configuration under Ubuntu
Deploy JDK+Tomcat8 under CentOS
Install ROS under ROS Ubuntu 18.04[2]
Install MySQL under Ubuntu
ubuntu install nginx server
Install Yarm-PM2 under Ubuntu
Tutorial for setting up FTP server in Ubuntu 16.04 environment
How to open https on nginx server under Ubuntu
CentOS7 deploy vsftp (FTP) service
Django&MySQL environment deployment under Ubuntu 14.04
[Linux] Build Samba server (ubuntu16.04)
Build OpenV** Server under CentOS7
Install OpenSSL 1.0.2 on Ubuntu Server 14.04
Ubuntu Server Chapter 8 DNS Service
Build OpenLDAP server under CentOS7
ubuntu 16.04 build pptpd V** server
Ubuntu Server Chapter 3 Package Management
Solve Unment dependencies under ubuntu
Configure tomcat on ubuntu server
Open SSH service under Ubuntu
Use sublime tex under ubuntu
Ubuntu Server Chapter 7 Remote Management
Server upgrade Ubuntu 20.04 LTS record
CentOS 7.2 deploy mail server (Postfix)
Jmeter (18)_Ubuntu deploy jmeter and ant
Build Ubuntu 12.04 cross compilation server
Modify shortcut keys under Ubuntu 18.04
Use of mediawiki under ubuntu
Server upgrade Ubuntu 20.04 LTS record
Install server-side Shadowsocks under Ubuntu 16.04
Open SSH service under Ubuntu
DNS service construction under Ubuntu
Ubuntu server builds Java web server
Method of setting up PHP operating environment under Ubuntu server
Use virtualbox to deploy ubuntu
Ubuntu deploys squid proxy server
Initial setup of Ubuntu 16.04 server
Ubuntu16.04 build GitLab server tutorial