设为首页 收藏本站
查看: 1611|回复: 0

[经验分享] pureftp、vsftp部署及优化

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-7-23 08:27:22 | 显示全部楼层 |阅读模式
pure-ftp部署及优化
pure-ftpd 官网 http://www.pureftpd.org/project/pure-ftpd
ftp服务器上:
[iyunv@ client mnt]# cd /usr/local/src/
[iyunv@ client src]#wget http://download.pureftpd.org/pub ... -ftpd-1.0.40.tar.gz
[iyunv@ client src]# tar zxvf pure-ftpd-1.0.40.tar.gz
[iyunv@ client src]# cd pure-ftpd-1.0.40
[iyunv@ client pure-ftpd-1.0.40]# ls
[iyunv@ client pure-ftpd-1.0.40]# ./configure \
--prefix=/usr/local/pureftpd \
--without-inetd \
--with-altlog \
--with-puredb \
--with-throttling \
--with-peruserlimits  \
--with-tls


[iyunv@ client pure-ftpd-1.0.40]# make
[iyunv@client pure-ftpd-1.0.40]# make install
[iyunv@client pure-ftpd-1.0.40]# ls /usr/local/pureftpd/
bin  sbin  share
[iyunv@client pure-ftpd-1.0.40]# mkdir -p /usr/local/pureftpd/etc/
[iyunv@client pure-ftpd-1.0.40]# cd configuration-file
[iyunv@client configuration-file]# cp pure-ftpd.conf /usr/local/pureftpd/etc/pure-ftpd.conf
[iyunv@client configuration-file]# cp pure-config.pl /usr/local/pureftpd/sbin/pure-config.pl
[iyunv@client configuration-file]# chmod 755 /usr/local/pureftpd/sbin/pure-config.pl
[iyunv@client configuration-file]# vim /usr/local/pureftpd/etc/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                        /usr/local/pureftpd/etc/pureftpd.pdb
LimitRecursion              3136 8
AnonymousCanCreateDirs      no
MaxLoad                     4
AntiWarez                   yes
Umask                       133:022
MinUID                      100
AllowUserFXP                no
AllowAnonymousFXP           no
ProhibitDotFilesWrite       no
ProhibitDotFilesRead        no
AutoRename                  no
AnonymousCantUpload         no
PIDFile                     /usr/local/pureftpd/var/run/pure-ftpd.pid
MaxDiskUsage               99
CustomerProof              yes

[iyunv@client configuration-file]# mkdir /tmp/ftp
[iyunv@client configuration-file]# tail /etc/passwd
tom:x:500:500::/home/tom:/bin/bash
[iyunv@client configuration-file]# chown -R tom:tom /tmp/ftp/
[iyunv@client configuration-file]# /usr/local/pureftpd/bin/pure-pw useradd ftpuser1  -utom -d /tmp/ftp
Password:
Enter it again:
//创建虚拟用户
[iyunv@client configuration-file]# /usr/local/pureftpd/bin/pure-pw mkdb
//创建密码文件
[iyunv@client configuration-file]# /usr/local/pureftpd/bin/pure-pw list
ftpuser1            /tmp/ftp/./
//列出用户

[iyunv@client configuration-file]# /usr/local/pureftpd/sbin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf
//启动

[iyunv@client configuration-file]# /etc/init.d/rpcbind stop
[iyunv@client configuration-file]# /etc/init.d/nfs stop

[iyunv@client configuration-file]# ps aux |grep pure
root     31728  0.0  0.0   9248   600 ?        Ss   17:27   0:00 pure-ftpd (SERVER)                                         
root     31730  0.0  0.0   4356   748 pts/0    S+   17:28   0:00 grep pure
[iyunv@client configuration-file]# netstat -lnp |grep ftp
tcp     0    0 0.0.0.0:21             0.0.0.0:*        LISTEN      31728/pure-ftpd (SE
tcp     0      0 :::21             :::*               LISTEN     31728/pure-ftpd (SE


[iyunv@client configuration-file]# lftp ftpuser1@192.168.137.21
Password:
lftp ftpuser1@192.168.137.21:~> ls
drwxr-xr-x    2 500        tom              4096 Jul 21 16:28 .
drwxr-xr-x    2 500        tom              4096 Jul 21 16:28 ..
lftp ftpuser1@192.168.137.21:~> mkdir 123
mkdir ok, `123' created
lftp ftpuser1@192.168.137.21:/> ls
drwxr-xr-x    3 500        tom              4096 Jul 21 16:36 .
drwxr-xr-x    3 500        tom              4096 Jul 21 16:36 ..
drwxr-xr-x    2 500        tom              4096 Jul 21 16:36 123
lftp ftpuser1@192.168.137.21:/> quit

[iyunv@client configuration-file]# ls /tmp/ftp/
123
[iyunv@client configuration-file]# tail /var/log/messages
[iyunv@client configuration-file]# cd /tmp/ftp/
[iyunv@client ftp]# touch 12.txt
[iyunv@client ftp]# vim 12.txt
12123

另一台客户端登入:
[iyunv@wangchao ~]#  lftp ftpuser1@192.168.137.21
Password:
lftp ftpuser1@192.168.137.21:/> ls
drwxr-xr-x    3 500        tom              4096 Jul 21 16:38 .
drwxr-xr-x    3 500        tom              4096 Jul 21 16:38 ..
-rw-r--r--    1 0          0                   6 Jul 21 16:38 12.txt
drwxr-xr-x    2 500        tom              4096 Jul 21 16:36 123
lftp ftpuser1@192.168.137.21:/> ?             //查看有哪些命令
lftp ftpuser1@192.168.137.21:/> get 12.txt
6 bytes transferred
lftp ftpuser1@192.168.137.21:/> quit
[iyunv@wangchao ~]# cat 12.txt
12123
[iyunv@wangchao ~]# vim 11.txt
555555555
[iyunv@wangchao ~]#  lftp ftpuser1@192.168.137.21
lftp ftpuser1@192.168.137.21:~> put 11.txt
10 bytes transferred
lftp ftpuser1@192.168.137.21:/> ls
drwxr-xr-x    3 500        tom              4096 Jul 21 16:48 .
drwxr-xr-x    3 500        tom              4096 Jul 21 16:48 ..
-rw-r--r--    1 500        tom                10 Jul 20 19:28 11.txt
-rw-r--r--    1 0          0                   6 Jul 21 16:38 12.txt
drwxr-xr-x    2 500        tom              4096 Jul 21 16:36 123
//上传成功



服务端:
[iyunv@client ftp]# ls
11.txt  123  12.txt
[iyunv@client ftp]# cat 11.txt                //查看上传的文件成功了
555555555



vsftp部署及优化
[iyunv@client ftp]# yum install -y vsftp
[iyunv@client ftp]# killall pure-ftpd
[iyunv@client ftp]# /etc/init.d/vsftpd start
[iyunv@client ftp]# lftp tom@192.168.137.21
Password:
lftp tom@192.168.137.21:~> ls
lftp tom@192.168.137.21:~>
//无文件

[iyunv@client ~]# ls /home/tom/                      //因为他的家目录下无任何文件
You have new mail in /var/spool/mail/root
[iyunv@client ~]# touch /home/tom/112.txt
[iyunv@client ~]# mkdir /home/tom/aabb
[iyunv@client tom]# ls
112.txt  aabb


客户端登入:
//查看已创建了文件
[iyunv@wangchao ~]# lftp tom@192.168.137.21
lftp tom@192.168.137.21:~> ls
-rw-r--r--    1 0        0               0 Jul 21 09:06 112.txt
drwxr-xr-x    2 0        0            4096 Jul 21 09:06 aabb
lftp tom@192.168.137.21:~> cd /etc/
cd ok, cwd=/etc
lftp tom@192.168.137.21:/etc>
lftp tom@192.168.137.21:/etc> ls                          
//进入etc目录下,此操作权限过大,存在安全隐患

服务端配置:
[iyunv@client tom]# vim /etc/vsftpd/vsftpd.conf
chroot_local_user=YES
[iyunv@client tom]# /etc/init.d/vsftpd restart




客户端登入:
[iyunv@wangchao ~]# lftp tom@192.168.137.21
Password:
lftp tom@192.168.137.21:~> cd /etc/
cd: Access failed: 550 Failed to change directory. (/etc)
lftp tom@192.168.137.21:/> cd /tmp/
cd: Access failed: 550 Failed to change directory. (/tmp)
lftp tom@192.168.137.21:/> pwd
ftp://tom@192.168.137.21/
lftp tom@192.168.137.21:/> ls
-rw-r--r--    1 0        0               0 Jul 21 09:06 112.txt
drwxr-xr-x    2 0        0            4096 Jul 21 09:06 aabb
//访问仅限在该目录下





建虚拟用户
[iyunv@client tom]# useradd virftp -s /sbin/nologin
[iyunv@client tom]# vim /etc/vsftpd/vsftpd_login           //创建用户密码文件
test1
111222
test2
aaa111
[iyunv@client tom]# chmod 600 /etc/vsftpd/vsftpd_login
[iyunv@client tom]# db_load -T -t hash -f /etc/vsftpd/vsftpd_login /etc/vsftpd/vsftpd_login.db

创建虚拟账号
[iyunv@client tom]# mkdir /etc/vsftpd/vsftpd_user_conf
[iyunv@client tom]# cd !$
cd /etc/vsftpd/vsftpd_user_conf
[iyunv@client vsftpd_user_conf]# vim test1
local_root=/home/virftp/test1
anonymous_enable=NO
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
idle_session_timeout=600
data_connection_timeout=120
max_clients=10
max_per_ip=5
local_max_rate=50000



[iyunv@client vsftpd_user_conf]# mkdir /home/virftp/test1     //创建该家目录
[iyunv@client vsftpd_user_conf]# chown -R virftp:virftp !$
chown -R virftp:virftp /home/virftp/test1
[iyunv@client vsftpd_user_conf]# vim /etc/pam.d/vsftpd
auth sufficient /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account sufficient /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login

//最开头两行添加,如果是64位系统改为/lib64/security/pam_userdb.so、/lib64/security/pam_userdb.so

[iyunv@client vsftpd_user_conf]# cat /etc/pam.d/vsftpd        //确保文件中写的目录存在
[iyunv@client vsftpd_user_conf]# ls /lib/security/pam_userdb.so
/lib/security/pam_userdb.so                            //存在

[iyunv@client vsftpd_user_conf]# vim /etc/vsftpd/vsftpd.conf
anonymous_enable=NO                      //匿名用户不能登入
local_enable=YES                           //本地系统用户可登入
anon_upload_enable=NO                    //匿名不可上传
anon_mkdir_write_enable=NO               //匿名不可创建

chroot_local_user=YES
guest_enable=YES                          //使虚拟用户可登入
guest_username=virftp                      // guest用户为virftp
virtual_use_local_privs=YES
user_config_dir=/etc/vsftpd/vsftpd_user_conf        //指定虚拟用户所在配置文件

[iyunv@client vsftpd_user_conf]# /etc/init.d/vsftpd restart
[iyunv@client vsftpd_user_conf]# cat /etc/vsftpd/vsftpd_login
test1
111222
test2
aaa111
[iyunv@client vsftpd_user_conf]# lftp test1@127.0.0.1
Password:
lftp test1@127.0.0.1:~> ls
lftp test1@127.0.0.1:/> pwd
ftp://test1@127.0.0.1/
[iyunv@client vsftpd_user_conf]# cd /home/virftp/test1/
[iyunv@client test1]# ls
[iyunv@client test1]# touch 2.txt
[iyunv@client test1]# mkdir 123
[iyunv@client test1]# lftp test1@127.0.0.1
Password:
lftp test1@127.0.0.1:~> ls
drwxr-xr-x    2 0        0            4096 Jul 21 10:13 123
-rw-r--r--    1 0        0               0 Jul 21 10:13 2.txt
//查看创建文件成功



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-89610-1-1.html 上篇帖子: vsftpd+ldap认证 下篇帖子: ubuntu安装vsftpd后出现 530 Login incorrect
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表