[LINUX] [CentOS 7.3] Build an FTP server on the ESXi host

Introduction

I tried to build an FTP server with CentOS 7.3 on the ESXi host. I will output the procedure for you who are looking at this article.

What is an FTP server in the first place?

A server that sends and receives files using FTP.

environment

item Description
Hypervisor ESXi6.7
OS CentOS7.3
[root@tspweb01 ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@tspweb01 ~]#

** * Minimal installation & the following settings have been implemented ** [Linux] Basic settings after OS installation of CentOS 7.3

Construction procedure

Create user for FTP connection

First, create a user to connect by FTP.

[root@tspweb01 ~]# useradd ftp-user
[root@tspweb01 ~]# passwd ftp-user
User ftp-Change user password.
new password:
Please re-enter your new password:
passwd:All authentication tokens have been successfully renewed.
[root@tspweb01 ~]#

Create directory for FTP

** ① Create directory for FTP **

[root@tspweb01 ~]# mkdir -p /var/www/ftp_dir

** ② Change the owner of the FTP directory **

[root@tspweb01 ~]# chown ftp-user /var/www/ftp_dir

** ③ Change the authority of the FTP directory **

[root@tspweb01 ~]# chmod 755 /var/www/ftp_dir

** ④ Check the FTP directory **

[root@tspweb01 ~]# ls -la /var/www | grep ftp
drwxr-xr-x.  2 ftp-user root 6 June 19 21:47 ftp_dir
[root@tspweb01 ~]#

FTP installation

--vsftpd installation

yum -y install vsftpd

--vsftpd installation confirmation

[root@tspweb01 ~]# rpm -qa | grep vsftpd
vsftpd-3.0.2-27.el7.x86_64
[root@tspweb01 ~]#

FTP settings

--FTP configuration file backup

[root@tspweb01 ~]# cp -p /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf_`date +'%Y%m%d'`
[root@tspweb01 ~]#
[root@tspweb01 ~]# ls -la /etc/vsftpd/
40 in total
drwxr-xr-x.2 root root 116 June 19 22:05 .
drwxr-xr-x.77 root root 8192 June 19 22:01 ..
-rw-------.1 root root 125 April 1 13:55 ftpusers
-rw-------.1 root root 361 April 1 13:55 user_list
-rw-------.1 root root 5116 April 1 13:55 vsftpd.conf
-rw-------.1 root root 5116 April 1 13:55 vsftpd.conf_20200619
-rwxr--r--.1 root root 338 April 1 13:55 vsftpd_conf_migrate.sh
[root@tspweb01 ~]#

--FTP settings

/etc/vsftpd/vsftpd.conf



#Confirm that there is the following description
~
## userlist_Enables the user specified in file (can connect)
userlist_enable=YES

##Access file (/etc/hosts.allow, /etc/hosts.deny)Is not used for access control
tcp_wrappers=NO

#Uncomment the following.

##Set local_Prohibit moving to directories above root
chroot_local_user=NO

##Enable chroot.
chroot_list_enable=YES

##Specifies the location of the chroot target user list file.
chroot_list_file=/etc/vsftpd/chroot_list

/etc/vsftpd/vsftpd.conf


#Add the following

##Allow passive mode connections
pasv_enable=YES

##Specify the IP address of the FTP server (when connecting in passive mode)
pasv_address=[FTP server IP]
* The above IP is fixed.

##Port specification
pasv_min_port=60001
pasv_max_port=60010
* If the port is a high port, there is no particular designation.

##Returns a list including files starting with a dot
force_dot_files=YES

##Display the time stamp of a file (or directory) in local time
use_localtime=YES

##Specify the location of the configuration file for each user.
user_config_dir=/etc/vsftpd/user_conf

Registration of user for FTP connection

/etc/vsftpd/chroot_list


ftp-user

Directory settings when logging in as an FTP user

Set the chroot to be "/ var / www / ftp_dir" when connecting with ftp-user

mkdir /etc/vsftpd/user_conf
vi /etc/vsftpd/user_conf/ftp-user

/etc/vsftpd/user_conf/ftp-user


local_root=/var/www/ftp_dir

Service start

systemctl start vsftpd

Verification

Start a command prompt from a Windows terminal and check the connection. There is no problem if you can log in to the FTP server as shown below.

C:\Users\owner>ftp 192.168.0.41
192.168.0.Connected to 41.
220 (vsFTPd 3.0.2)
200 Always in UTF8 mode.
user(192.168.0.41:(none)): ftp-user ← Enter user name
331 Please specify the password. 
password: ← password入力
230 Login successful.
ftp>

By the way, the location of the root directory is as follows.

ftp> pwd
257 "/var/www/ftp_dir"
ftp>

Reference article

[For beginners] Build an FTP server with CentOS 7

Recommended Posts

[CentOS 7.3] Build an FTP server on the ESXi host
Build an NFS server on Arch Linux
Build jupyter notebook on remote server (CentOS)
Build CentOS 8 on ESXi 6.7 with minimal configuration
Access the host SQL Server with python27 / pyodbc on the container
Build a python environment on CentOS 7.7 for your home server
Build a python3 environment on CentOS7
Notes on using matplotlib on the server
Host the network library Mirror for Unity on a Linux server
Build a Pypi cache server on QNAP
Insufficient var space on the mail server
Build a simple WebDAV server on Linux
Build CGI Server running on Python 3 on Docker
Build an LNPP environment on Amazon Linux 2
Build a Samba server on Arch Linux
Build WordPress on CentOS 8 in LAMP environment
Deploy CentOS 6.10 x86_64 on VMware vSphere ESXi 5.5
Build a web server on your Chromebook
Publish the current directory on the web server
Encrypt ACME on Alibaba Cloud: Build an ACME request and sign the JWS payload
Stray build Python-3.8.5 on CentOS without root privileges
Run the task in the background on the sshed server
Drawing tips with matplotlib on the server side
Build a python environment with ansible on centos6
Launch an HTTP server in the current directory
Create an account from CentOS mail server construction
[Python] I will upload the FTP to the FTP server.
Remotely open Jupyter notebook launched on the server
Build an Arch Linux environment on Raspberry Pi
How to set a shared folder with the host OS in CentOS7 on VirtualBOX
A story about an engineer who came only on the server side created a portfolio
I tried studying on the WEB server side at an in-house Python study session