0

Proftpd 新手的学习笔记

已有 174 阅读此文人 - - Linux,系统管理 -

我配置是一个简单的FTP服务器,所达到的要求是:
1、 允许匿名访问
2、 允许skate用户能够上传文件而不能进行删除和修改之类的权限
3、 允许tc用户可以对整个FTP进行上传修改和删除的所有的权限
准备好了,现在开始了!!
一、安装proftpd软件(注意哦:我每一次安装时是用测试版的,就是proftpd-1.3.0rc1版的,之后出现了严重的错误,这个版不稳定,大家如果不是玩玩的话就不要用测试版的,会气死的!!
),http://www.proftpd.org.下载下来的是一个压缩包,用
tar zxvf proftpd-1.2.10tar.gz 进行解压
cd proftpd-1.2.10 进入proftpd-1.2.10文件夹
./configure –-prefix=/etc/proftpd 把proftpd-1.2.10安装到/etc/proftpd文件夹下
Make
Make install
二、新建skate,tc用户
groupadd skate 创建一个skate组

useradd skate –g skate –d /var/ftp/skate –s /sbin/nologin  这句话我的理解是(新建skate用户,并把它加入skate组,把skate的目录建在/var/ftp目录下,并指定它的shell为nologin,这个 nologin并不能让skate用户进入linux系统

passwd skate 设置skate的密码

useradd –d /var/ftp tc 添加tc用户,并把它的家目录建在/var/ftp,这样只要此用户登录的话可以直接进入ftp的目录下
passwd tc 设置tc的密码

gpasswd -a skate tc
gpasswd -a tc skate
chown tc.tc /var/ftp
chmod -R 770 skate
cd ..
chmod -R 775 ftp
vi /etc/proftpd/etc/proftpd.conf
service proftpd start
service proftpd restart
chmod 775 ftp
chmod -R 770 skate

好了,用户设置好了 : )

三、在开始配置proftpd.conf文件之前进行以下操作:
1、因为我用的是红帽子AS4.0的,所以先要把自带的vsftpd给停掉
service vsftpd stop 或者直接 rpm –e vsftpd
2、设置一个proftpd的启动服务
编辑一个启动脚本,
cd proftpd-1.2.10 进入proftpd-1.2.10的解压文件夹中
cp contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd 拷贝proftpd.init.d到/etc/rc.d/init.d文件夹中,并改名为proftpd
vi /etc/rc.d/init.d/proftpd 编辑这个文件,找到文件中有一行是PATH行,将它改成你所安装proftpd所在的目录。PATH=’$PATH:/etc/proftpd/sbin:/etc/proftpd/bin’ 我是安装在/etc/proftpd文件下,保存退出
3、把/etc/rc.d/init.d/proftpd设成可执行文件
chmod +x /etc/rc.d/init.d/proftpd
chkonfig –add proftpd
这样就可以用service proftpd start和service proftpd stop 和service proftpd restart来分别执行开启服务,停止服务与重启服务
4、现在你用service proftpd start是不是会出现个错误,差点忘了要改配置文件了,嘻
vi /etc/proftpd/etc/proftpd.conf
在全局配置里把group的值为nogroup改成nobody
好了,配置前的工作做好了
四、现在正式来配置proftpd.conf里的权限设置,
vi /etc/proftpd/etc/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 "ProFTPD Default Installation"
ServerType standalone
DefaultServer 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   nobody
Group nobody (这边就是我在上一步所讲的设置成nobody)

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~ skate,skate  (阻止skate组的用户到其他目录,它们只能呆在自家目录)

# Normally, we want files to be overwriteable.
AllowOverwrite on

# Bar use of SITE CHMOD by default ;
DenyAll
;

# A basic anonymous configuration, no upload directories. If you do not
# want anonymous users, simply delete this entire ; section.
;
User ftp
Group ftp

# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp

# Limit the maximum number of anonymous logins
MaxClients 10

# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayFirstChdir .message

# Limit WRITE everywhere in the anonymous chroot ;
DenyAll
;
;

;  
AllowOverwrite on
AllowStoreRestart on
#AllowForeignAddress on ;
AllowAll
;
; 

; ;
DenyUser skate
;
; (这几句是对skate用户的权限限制,只允许它对/var/ftp/skate有写的权限,不允许它有DELE RNFR RNTO RMD XRMD的权限)

; ;
AllowUser tc
;
;  (这几句是对tc的权限设置,给它对/var/ftp目录拥有所有的权限,这个用户也算是FTP的管理员帐户吧。)
存盘退出
service proftpd restart
五、修改一下/var/ftp目录的权限
chmod –R 775 /var/ftp 
这样tc对/var/ftp/skate的文件具有写,删,改,执行的所有权限。

想动手了吧!那就试验一次吧!

期待你一针见血的评论,Come on!

不用想啦,马上 "登录"  发表自已的想法.