当前位置:首页 > 服务器类 > FTP服务器 > > Linux 下如何利用proftpd构架一个ftp服务器

Linux 下如何利用proftpd构架一个ftp服务器

点击次数:25 次 发布日期:2008-11-22 09:26:26 作者:源代码网
源代码网推荐

源代码网整理以下这篇文章针对那些希望利用ftp协议和朋友们共享文件的人们,就像windows下的FTPserU,我提供的方式不是唯一的,希望我的方法足够清晰。这个FTPserver只允许拥有正确密码的人使用,所以你要明白只有已知的用户才能读取你的FTP服务。

源代码网整理以下1- 使用下面的命令安装proftpd:

源代码网整理以下Code:

源代码网整理以下sudo apt-get install proftpd

源代码网整理以下2- 在etc/shells 加入如下代码 (sudo gedit /etc/shells to open the file)(译注:命令行模式下sudo vi /etc/shells):

源代码网整理以下Code:

源代码网整理以下/bin/false

源代码网整理以下新建一个 /home/FTP-shared 目录:

源代码网整理以下Code:

源代码网整理以下cd /home

源代码网整理以下sudo mkdir FTP-shared

源代码网整理以下创建一个只能用来读取ftp的用户userftp。这个用户不需要有效的shell(更安全),所以选择 /bin/false shell 给 userftp,/home/FTP-shared 作为主目录。

源代码网整理以下为了是这部分更清楚,我给取此操作的命令行:

源代码网整理以下Code:

源代码网整理以下sudo useradd userftp -p your_password -d /home/FTP-shared -s /bin/false

源代码网整理以下在FTP-shared 目录下新建一个download和一个upload 目录:

源代码网整理以下Code:

源代码网整理以下cd /home/FTP-shared/

源代码网整理以下sudo mkdir download

源代码网整理以下sudo mkdir upload

源代码网整理以下现在我们来给它们设置相应的权限:

源代码网整理以下Code:

源代码网整理以下cd /home

源代码网整理以下sudo chmod 755 FTP-shared

源代码网整理以下cd FTP-shared

源代码网整理以下sudo chmod 755 download

源代码网整理以下sudo chmod 777 upload

源代码网整理以下3- 好了,现在进入proftpd的配置文件:

源代码网整理以下

以下为引用的内容:

源代码网整理以下Code:

源代码网整理以下sudo gedit /etc/proftpd.conf

源代码网整理以下当然你可以按你的需要编辑你自己的proftpd.conf:

源代码网整理以下Code:
# To really apply changes reload proftpd after modifications.
AllowOverwrite on
AuthAliasOnly on

源代码网整理以下# Choose here the user alias you want !!!!
UserAlias sauron userftp

源代码网整理以下ServerName   "ChezFrodon"
ServerType    standalone
DeferWelcome   on

源代码网整理以下MultilineRFC2228 on
DefaultServer   on
ShowSymlinks   off

源代码网整理以下TimeoutNoTransfer 600
TimeoutStalled 100
TimeoutIdle 2200

源代码网整理以下DisplayFirstChdir               .message
ListOptions                 "-l"

源代码网整理以下RequireValidShell   off

源代码网整理以下TimeoutLogin 20

源代码网整理以下RootLogin    off

源代码网整理以下# It"s better for debug to create log files ;-)
ExtendedLog    /var/log/ftp.log
TransferLog    /var/log/xferlog
SystemLog   /var/log/syslog.log

源代码网整理以下#DenyFilter   *.*/

源代码网整理以下# I don"t choose to use /etc/ftpusers file (set inside the users you want to ban, not useful for me)
UseFtpUsers off

源代码网整理以下# Allow to restart a download
AllowStoreRestart  on

源代码网整理以下# Port 21 is the standard FTP port, so don"t use it for security reasons (choose here the port you want)
Port    1980

源代码网整理以下# 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 8

源代码网整理以下# Set the user and group that the server normally runs at.
User                  nobody
Group                 nogroup

源代码网整理以下# Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable.
Umask    022 022

源代码网整理以下PersistentPasswd  off

源代码网整理以下MaxClients 8
MaxClientsPerHost 8
MaxClientsPerUser 8
MaxHostsPerUser 8

源代码网整理以下# Display a message after a successful login
AccessGrantMsg "welcome !!!"
# This message is displayed for each access good or not
ServerIdent                  on       "you"re at home"

源代码网整理以下# Set /home/FTP-shared directory as home directory
DefaultRoot /home/FTP-shared

源代码网整理以下# Lock all the users in home directory, ***** really important *****
DefaultRoot ~

源代码网整理以下MaxLoginAttempts    5

源代码网整理以下#VALID LOGINS
<Limit LOGIN>
AllowUser userftp
DenyALL
</Limit>

源代码网整理以下<Directory /home/FTP-shared>
Umask 022 022
AllowOverwrite off
 <Limit MKD STOR DELE XMKD RNRF RNTO RMD XRMD>
 DenyAll
 </Limit>
</Directory>

源代码网整理以下<Directory /home/FTP-shared/download/*>
Umask 022 022
AllowOverwrite off
 <Limit MKD STOR DELE XMKD RNEF RNTO RMD XRMD>
 DenyAll
 </Limit>
</Directory>

源代码网整理以下<Directory> /home/FTP-shared/upload/>
Umask 022 022
AllowOverwrite on
 <Limit READ RMD DELE>
       DenyAll
     </Limit>

源代码网整理以下     <Limit STOR CWD MKD>
       AllowAll
     </Limit>
</Directory>

源代码网整理以下好了,你已经完成了proftpd的配置,你的服务端口是1980,而读取的参数如下,用户:sauron,密码:你为userftp设置的那个。

源代码网整理以下4- 启动/停止/重启动你的服务:

源代码网整理以下Code:

源代码网整理以下sudo /etc/init.d/proftpd start

源代码网整理以下sudo /etc/init.d/proftpd stop

源代码网整理以下sudo /etc/init.d/proftpd restart

源代码网整理以下对你的proftpd进行一下语法检查:

源代码网整理以下Code:

源代码网整理以下sudo proftpd -td5

源代码网整理以下想知道谁现在连接到你的服务,用ftptop命令(使用字母"t"来转换显示频率),你也可以使用"ftpwho"命令。

源代码网供稿.
网友评论 (0)
会员中心
服务器类
本站推荐
服务器类之精华