Tag Archives: pure-ftpd

Command: MLSD Error: The data connection could not be established: ECONNREFUSED – Connection refused by server

Command: MLSD
Error: The data connection could not be established: ECONNREFUSED - Connection refused by server
Error: Connection timed out after 60 seconds of inactivity
Error: Failed to retrieve directory listing

echo "40000 45000" > /etc/pure-ftpd/conf/PassivePortRange
echo "1.2.3.4" > /etc/pure-ftpd/conf/ForcePassiveIP

service pure-ftpd restart

pure-ftpd ubuntu


apt update
apt install -y pure-ftpd

rm -rf /etc/pure-ftpd/conf/* \
&& echo "clf:/var/log/pure-ftpd/transfer.log" > /etc/pure-ftpd/conf/AltLog \
&& echo "UTF-8" > /etc/pure-ftpd/conf/FSCharset \
&& echo "1000" > /etc/pure-ftpd/conf/MinUID \
&& echo "yes" > /etc/pure-ftpd/conf/NoAnonymous \
&& echo "no" > /etc/pure-ftpd/conf/PAMAuthentication \
&& echo "no" > /etc/pure-ftpd/conf/UnixAuthentication \
&& echo "/etc/pure-ftpd/pureftpd.pdb" > /etc/pure-ftpd/conf/PureDB \
&& touch /etc/pure-ftpd/pureftpd.pdb \
&& echo "027 007" > /etc/pure-ftpd/conf/Umask \
&& echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone \
&& echo "yes" > /etc/pure-ftpd/conf/Daemonize \
&& echo "yes" > /etc/pure-ftpd/conf/DontResolve \
&& echo "no" > /etc/pure-ftpd/conf/BrokenClientsCompatibility \
&& echo "50" > /etc/pure-ftpd/conf/MaxClientsNumber \
&& echo "no" > /etc/pure-ftpd/conf/VerboseLog \
&& echo "yes" > /etc/pure-ftpd/conf/DisplayDotFiles \
&& echo "no" > /etc/pure-ftpd/conf/AnonymousOnly \
&& echo "ftp" > /etc/pure-ftpd/conf/SyslogFacility \
&& echo "no" > /etc/pure-ftpd/conf/AnonymousCanCreateDirs \
&& echo "30000 50000" > /etc/pure-ftpd/conf/PassivePortRange \
&& echo "no" > /etc/pure-ftpd/conf/AllowUserFXP \
&& echo "no" > /etc/pure-ftpd/conf/AllowAnonymousFXP \
&& echo "no" > /etc/pure-ftpd/conf/ProhibitDotFilesWrite \
&& echo "no" > /etc/pure-ftpd/conf/ProhibitDotFilesRead \
&& echo "no" > /etc/pure-ftpd/conf/AutoRename \
&& echo "yes" > /etc/pure-ftpd/conf/AnonymousCantUpload \
&& ln -sf /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/50pure \
&& ln -sf /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/40PureDB \
&& systemctl stop pure-ftpd \
&& systemctl start pure-ftpd \
&& systemctl status pure-ftpd

# To enable both plain-text and TLS encryption
echo "1" > /etc/pure-ftpd/conf/TLS

# Or disable plain-text and use TLS encryption only
echo "2" > /etc/pure-ftpd/conf/TLS

apt install -y certbot
certbot certonly --standalone --agree-tos --cert-name ftp.yourdomain.tld -n -m [email protected] -d ftp.yourdomain.tld -d ftp2.yourdomain.tld --pre-hook "service apache2 stop" --post-hook "service apache2 start"

echo $(certbot certonly --standalone --agree-tos --cert-name ftp.yourdomain.tld -n -m [email protected] -d ftp.yourdomain.tld -d ftp2.yourdomain.tld --pre-hook "service apache2 stop" --post-hook "service apache2 start") \
cd /etc/letsencrypt/live/ftp.yourdomain.tld/ \
&& cat cert.pem privkey.pem > pure-ftpd.pem \
&& rm /etc/ssl/private/pure-ftpd.pem \
&& mv pure-ftpd.pem /etc/ssl/private/ \
&& chmod 600 /etc/ssl/private/pure-ftpd.pem \
&& service pure-ftpd restart

#Add new user
groupadd ftpgroup
useradd -g ftpgroup -d /dev/null -s /etc ftpuser -d /home/ftpuser
chown -R ftpuser:ftpgroup /home/ftpuser

pure-pw useradd ftpaccountname -u ftpuser -g ftpgroup -d /home/ftpuser
pure-pw mkdb
pure-pw show ftpaccountname

#Reset FTP User Password
pure-pw list
pure-pw passwd ftpaccountname
pure-pw mkdb

#Delete FTP User
pure-pw userdel ftpaccountname
pure-pw mkdb

systemd[1]: Can’t open PID file /var/run/pure-ftpd.pid (yet?) after start: Too many levels of symbolic links

systemd[1]: Can’t open PID file /var/run/pure-ftpd.pid (yet?) after start: Too many levels of symbolic links
systemd[1]: pure-ftpd.service start operation timed out. Terminating.
systemd[1]: Failed to start Pure-FTPd FTP server.
systemd[1]: Unit pure-ftpd.service entered failed state.
systemd[1]: pure-ftpd.service failed.

vi /usr/lib/systemd/system/pure-ftpd.service

[Service]
Type=forking
#PIDFile=/var/run/pure-ftpd.pid
PIDFile=/run/pure-ftpd.pid
ExecStart=/usr/sbin/pure-config.pl /etc/pure-ftpd/pure-ftpd.conf –daemonize

systemctl daemon-reload
systemctl start pure-ftpd

pure-ftpd and virtual users on CentOS

You should install pure-ftpd
yum install pure-ftpd
If you are using Fedora also pure-ftpd-selinux

mkdir /webs/web1/public_html
chown web1:web1 /webs/web1/public_html
pure-pw useradd web1_ftp -u web1 -g web1 -d /webs/web1/public_html
pure-pw mkdb
pure-pw list
web1_ftp is your virtual user name

You should remember enable: PureDB /etc/pure-ftpd/pureftpd.pdb in your pure-ftpd main configuration file and disable anonymous access: NoAnonymous yes