安装 Pure-ftpd
yum 安装
yum -y install pure-ftpd
修改配置文件
vim /etc/pure-ftpd/pure-ftpd.conf
ChrootEveryone yes BrokenClientsCompatibility no MaxClientsNumber 50 Daemonize yes MaxClientsPerIP 8 VerboseLog no DisplayDotFiles yes AnonymousOnly no NoAnonymous no SyslogFacility ftp DontResolve yes MaxIdleTime 15 PureDB /etc/pure-ftpd/pureftpd.pdb PAMAuthentication yes LimitRecursion 10000 8 AnonymousCanCreateDirs no MaxLoad 4 AntiWarez yes Umask 133:022 MinUID 1000 AllowUserFXP no AllowAnonymousFXP no ProhibitDotFilesWrite no ProhibitDotFilesRead no AutoRename no AnonymousCantUpload yes AltLog clf:/var/log/pureftpd.log PIDFile /var/run/pure-ftpd.pid MaxDiskUsage 99 CustomerProof yes
创建系统用户
useradd www
更改所属主和所属组:
chown -R www:www /data/www/wordpress
创建ftp用户
pure-pw useradd user005 -u www -d /data/www/wordpress
此时会出现为该ftp新用户创建密码的提示:
pure-pw useradd user005 -u www -d /data/www/wordpress Password: Enter it again:
-u选项将虚拟用户user005与系统用户www关联在一起,即使用user005账号登录FTP后,会以www的身份来读取和下载文件。
-d选项后面的目录为user005账户的家目录,这样可以使user005只能访问其家目录/data/www/wordpress
创建用户信息数据库文件:
pure-pw mkdb
查看用户列表:
pure-pw list
pure-pw list user005 /data/www/wordpress/./
启动pure-ftpd/添加开机启动
systemctl start pure-ftpd systemctl enable pure-ftpd
测试连接
ftp 127.0.0.1
[root@localhost pure-ftpd]# ftp 127.0.0.1 Connected to 127.0.0.1 (127.0.0.1). 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 1 of 50 allowed. 220-Local time is now 20:45. Server port: 21. 220-IPv6 connections are also welcome on this server. 220 You will be disconnected after 15 minutes of inactivity. Name (127.0.0.1:root): user005 331 User user005 OK. Password required Password: 230 OK. Current directory is / Remote system type is UNIX. Using binary mode to transfer files. ftp>
登录成功
添加新的ftp用户
pure-pw useradd user006 -u www -d /data/www/wordpress
pure-pw useradd user006 -u www -d /data/www/wordpress 输入密码 Password: Enter it again:
创建新的ftp用户之后,需要重新生成用户数据库文件,新的账户才能登录。
pure-pw mkdb
删除账号的命令为:
pure-pw userdel user006
修改ftp用户的密码
pure-pw passwd user006 #修改密码 Password: Enter it again:
pure-pw mkdb #重新生成数据库文件
修改用户的上传路径
pure-pw usermod user006 -d /data/www/web pure-pw mkdb
pure-pw show user006 #查看用户信息
[root@localhost ~]# pure-pw show user006 Login : user006 Password : $6$1eHOVB9O/aDbkn30$/ftGMK2dBTHlk.uqYoEYRZ6T.DKobaXjPTshLIMgpCdVbBSEBWpvOHtGxsLRRfFexiGse7tSdCiUlBl3wlPOF. UID : 1001 (www) GID : 1001 (www) Directory : /data/www/web/./ Full name : Download bandwidth : 0 Kb (unlimited) Upload bandwidth : 0 Kb (unlimited) Max files : 0 (unlimited) Max size : 0 Mb (unlimited) Ratio : 0:0 (unlimited:unlimited) Allowed local IPs : Denied local IPs : Allowed client IPs : Denied client IPs : Time restrictions : 0000-0000 (unlimited) Max sim sessions : 0 (unlimited)
调整pure-ftpd日志文件的路径,默认把日志写在/var/log/messages
~这个按需求,一般不用调整~
修改/etc/rsyslog.conf
在这行的cron.none后面添加 ;ftp.none 使ftp的日志信息成私有,(我这里直接注释,新加一行。)
vim /etc/rsyslog.conf
... #*.info;mail.none;authpriv.none;cron.none /var/log/messages *.info;mail.none;authpriv.none;cron.none;ftp.none /var/log/messages ftp.* -/var/log/pureftpd.log #pure-ftpd的日志输出文件 ...
注意: 不要去掉/var前面的-号,否则日志会在/var/log/messages与/var/log/pureftpd.log里各记录一份。
重启rsyslog生效
systemctl restart rsyslog.service
修改主端口
vim /etc/pure-ftpd/pure-ftpd.conf
#Bind 127.0.0.1,21 修改为 Bind 0.0.0.0,8121
端口修改为8121
重启pure-ftpd
systemctl restart pure-ftpd
PureFTP被动端口设置
vim /etc/pure-ftpd/pure-ftpd.conf
# PassivePortRange 30000 50000 修改为 PassivePortRange 30000 50000 把前面的#删除