Ubuntu搭建proftpd服务器

引言

工作需要前端工程师在测试环境测试,但是前端工程师大多不用LINUX,调试起来我这种兼职运维的就是一个苦逼了,因此搭建一个FTP服务器方便前端工程师部署调试自己的代码

搭建proftpd服务器

安装proftpd

sudo apt-get install proftpd


配置proftpd

vim /etc/proftpd/proftpd.conf

# This is a basic ProFTPD configuration file (rename it to 
# 'proftpd.conf' for actual use.  It establishes a single server
# and a single anonymous login.  It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.

ServerName			"HAO GEEK TEAM"
ServerIdent 			on	"Welcome To Hao Geek!"
ServerType			standalone
DefaultAddress			192.168.1.***
SocketBindTight			on

# Port 21 is the standard FTP port.
Port				21

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask				022

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances			30

# Set the user and group under which the server will run.
User				www-data
Group				www-data

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot /srv/www/test/
AllowOverwrite		yes

# Normally, we want files to be overwriteable.
<Directory /srv/www/test/test1>
<Limit WRITE>
AllowUser wangzhengyi
DenyAll
</Limit>
</Directory>

# 设置客户端认证方式,通过文件认证
AuthOrder                               mod_auth_file.c mod_auth_unix.c
# 指定文件认证的passwd文件
AuthUserFile   /etc/proftpd/ftp.passwd
# 指定文件认证的group文件
AuthGroupFile  /etc/proftpd/ftp.group
# 认证帐号不需要有有效的shell
RequireValidShell    off
# 设置每秒接受的连接请求个数,防止DoS攻击
MaxConnectionRate       5
# 最大的连接上的client的数量
MaxClients   20 "Sorry,the maximum number of allowed users (%m) are already connected. "
# 允许端点续传
AllowStoreRestart   on
#关闭dns反向解析
UseReverseDNS off
IdentLookups off

ftpasswd创建访问用户

sudo ftpasswd --passwd --file=/etc/proftpd/ftp.passwd --name=wangzhengyi --uid=33 --shell=/bin/false --home=/home/nohome
每个参数的定义可以man一下,如果你完全抄袭我的,那我只能说你运维做的太傻逼了,动动脑子想想自己的需求还是很必要的!

重启proftpd服务器

sudo  /etc/init.d/proftpd  restart

proftpd权限控制

目的

实现不同的用户不同的根目录

需求

目录结构如下:
--root(根目录):
--test1(子目录1)
--test2(子目录2)
--test3(子目录3)

有三个用户user1,user2,user3,user1默认到/root目录下,user1默认到/root/test1目录下,user2默认到/root/test2目录下

实现方法

(1)设置user1的home目录为/root,user1的home目录为/home/test1,user2的home目录为/home/test2,设置方法:

sudo ftpasswd --passwd --file=/etc/proftpd/ftp.passwd --name=wangzhengyi --uid=33 --shell=/bin/false --home=/root{ /test1 /test2}

(2)增加权限控制
DefaultRoot /root
<Directory /root/test1>
<Limit WRITE>
AllowUser user1
DenyAll
</Limit>
</Directory>

<Directory /root/test2>
<Limit WRITE>
AllowUser user2
DenyAll
</Limit>
</Directory>

原理

用户登录FTP服务器后,proftpd会默认首先寻找该系统用户的/home目录,并将该目录与proftpd.conf文件中的相关配置进行匹配,若无匹配,则转至proftpd.conf文件中的DefaultRoot命令登录服务器默认的根目录

参考链接



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值