---
# System prepended metadata

title: VSFTPd with TLS (in CentOS7)
tags: [VSFTPD, OpenSSL, TLS]

---

VSFTPd with TLS (in CentOS7)

```
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO

# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES

# Uncomment this to enable any form of FTP write command.
write_enable=YES

#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022

#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES

#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES

#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES

#
# Activate logging of uploads/downloads.
xferlog_enable=YES
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES

#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not recommended!
#chown_uploads=YES
#chown_username=ryosaeba

#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
xferlog_file=/var/log/vsftpd.log
vsftpd_log_file=/var/log/vsftpd.log
dual_log_enable=YES
wc_logs_enable=YES
# Log the FTP connection actions
log_ftp_protocol=YES

#
# If you want, you can have your log file in standard ftpd xferlog format.
xferlog_std_format=YES

#
# Enable the FTP process -OWNER/RUNNER-. Makesure if this is u wanna~
setproctitle_enable=YES

# You may change the default value for timing out an idle session.
#idle_session_timeout=600

#Active Mode
connect_timeout=180
#Passive Mode
accept_timeout=180

#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120

#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#ftpd_banner=Welcome to blah FTP service.
ftpd_banner=Welcome to  Iserlohn FTP service.

# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES
chroot_list_enable=YES
#
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list

# Solve the chroot directory permission Error:
# GnuTLS error -15: An unexpected TLS packet was received.
# Disconnected from server: ECONNABORTED - Connection aborted
# Failed to retrieve directory listing
allow_writeable_chroot=YES

# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
#listen=NO
listen=YES

#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on both IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=NO

pam_service_name=vsftpd
tcp_wrappers=YES
max_clients=10
max_per_ip=7
#
max_login_fails=5
# Allow 10M
local_max_rate=10240000
# Default ON, will be hung for 20Secs to wait the DNS resolve(If DNS no response)
reverse_lookup_enable=NO


# Deny list for users, userlist_deny=NO lets user in /etc/vsftpd.user_list FTP
userlist_deny=YES
# userlist_enable=YES
userlist_enable=YES
userlist_file=/etc/vsftpd/user_list

# Download permission for all
download_enable=NO
# User specified configuration
user_config_dir=/etc/vsftpd/user_conf
#

# Enable SSL. Only RSA
#dsa_cert_file=/etc/ssl/private/VSFSelfsigned.pem
#dsa_private_key_file=/etc/ssl/private/VSFPrivate.key
rsa_cert_file=/etc/ssl/private/VSFSelfsigned.pem
rsa_private_key_file=/etc/ssl/private/VSFPrivate.key


#SSL Related setting
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES

#Default FTPS ports (TCP: 989, 990)
listen_port=990
pasv_enable=YES
pasv_min_port=50100
pasv_max_port=51100
pasv_addr_resolve=NO
#local_root=/tmp
strict_ssl_read_eof=NO
strict_ssl_write_shutdown=NO

ssl_tlsv1=NO
ssl_tlsv1_1=NO
ssl_tlsv1_2=YES
ssl_sslv2=NO
ssl_sslv3=NO
#debug_ssl=YES
debug_ssl=NO
#implicit_ssl=YES --- NOT WORKED!?
implicit_ssl=NO

require_cert=NO
require_ssl_reuse=NO
#require_ssl_reuse=YES
#ssl_ciphers=DES-CBC3-SHA
ssl_ciphers=HIGH
```


 Certification generated by OpenSSL
 2A) For VSFTP SSL(ECDSA-SHA384) --- Checked OK
1. Generate key for Certificate Authority
```
openssl ecparam -out CA_secp384r1.key -name secp384r1 -genkey
```
2. Create Self Signed Certificate for CA

```
openssl req -x509 -nodes -days 3650 -new -key CA_secp384r1.key -keyout VSFPrivate.key -out VSFSelfsigned.pem -outform pem -sha384
```
2B) For VSFTP SSL(ECDSA-SHA3-512) --- Enhanced cipher. Use this ONE(Prime field.  Binary field would get more attacking vectors)
1. Generate key for Certificate Authority
```		
openssl ecparam -out CA_secp521r1.key -name secp521r1 -genkey
```
2. Create Self Signed Certificate for CA
```
openssl req -x509 -nodes -days 3651 -new -key CA_secp521r1.key -keyout VSFPrivate.key -out VSFSelfsigned.pem -outform pem -sha3-512
```

~*銀河的歷史又翻過了一頁*~ 
*Jun 26, 2024*
