Chinaunix首页 | 论坛 | 博客
  • 博客访问: 361505
  • 博文数量: 150
  • 博客积分: 3423
  • 博客等级: 中校
  • 技术积分: 1005
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-15 09:04
文章分类

全部博文(150)

文章存档

2012年(2)

2011年(148)

分类: 系统运维

2011-08-08 20:39:39

      ubuntu下如何利用proftpd构架一个ftp服务 器:proftpd(Professional FTP daemon),是针对Wu-FTP的弱项而开发的。除了改进其安全性,还有具备许多Wu-FTP所没有的特点。比如,能以Stand-alone、 xinetd模式运行。ProFTP不仅配置方便,而且有MySQL模块,本文主要讲述的是ubuntu下利用proftpd搭建ftp服务器。

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

1- 使用下面的命令安装proftpd:

  1. sudo apt-get install proftpd

2- 在etc/shells 加入如下代码:

  1. sudo gedit /etc/shells

命令行模式下:sudo vi /etc/shells

  1. /bin/false

新建一个 /home/FTP-shared 目录 :

  1. cd /home

  2. sudo mkdir FTP-shared
创建一个只能用来读取ftp的用户userftp. 这个用户不需要有效的shell(更安全) ,所以选择 /bin/false shell 给 userftp , /home/FTP-shared 作为主目录.

为了是这部分更清楚,我给取此操作的命令行:
  1. sudo useradd userftp -p your_password -d /home/FTP-shared -s /bin/false

在FTP-shared 目录下新建一个download和一个upload 目录:
  1. cd /home/FTP-shared/
  2.  
  3. sudo mkdir download

  4. sudo mkdir upload
现在我们来给它们设置相应的权限:

  1. cd /home

  2. sudo chmod 755 FTP-shared

  3. cd FTP-shared

  4. sudo chmod 755 download

  5. sudo chmod 777 upload
3- proftpd的配置文件:

  1. sudo gedit /etc/proftpd.conf
当然你可以按你的需要编辑你自己的proftpd.conf:

  1. #To really apply changes reload proftpd after modifications.

  2. AllowOverwrite on

  3. AuthAliasOnly on

  4. #Choose here the user alias you want !!!!
  5.   
  6. UserAlias sauron userftp
  7.  
  8. ServerName "ChezFrodon"
  9.  
  10. ServerType standalone

  11. DeferWelcome on
  12.   
  13. MultilineRFC2228 on
  14.   
  15. DefaultServer on
  16.  
  17. ShowSymlinks off
  18.  
  19. TimeoutNoTransfer 600

  20. TimeoutStalled 100
  21.  
  22. TimeoutIdle 2200
  23.  
  24. DisplayFirstChdir .message
  25.   
  26. ListOptions "-l"
  27.  
  28. RequireValidShell off

  29. TimeoutLogin 20
  30.  
  31. RootLogin off
  32.  
  33. # It's better for debug to create log files ;-)
  34.  
  35. ExtendedLog /var/log/ftp.log
  36.  
  37. TransferLog /var/log/xferlog
  38.  
  39. SystemLog /var/log/syslog.log
  40.   
  41. #DenyFilter \*.*/

  42. # I don't choose to use /etc/ftpusers file
  43. # (set inside the users you want to ban, not useful #for me)
  44.   
  45. UseFtpUsers off
  46.   
  47. # Allow to restart a download

  48. AllowStoreRestart on
  49.  
  50. # Port 21 is the standard FTP port
  51. # so don't use it for security reasons (choose here the #port you want)
  52.   
  53. Port 1980
  54.  
  55. # To prevent DoS attacks, set the maximum number of child processes
  56.  
  57. # to 30. If you need to allow more than 30 concurrent connections
  58.  
  59. # at once, simply increase this value. Note that this ONLY works
  60.   
  61. # in standalone mode, in inetd mode you should use an inetd server
  62.  
  63. # that allows you to limit maximum number of processes per service
  64.  
  65. # (such as xinetd)
  66.  
  67. MaxInstances 8
  68.   
  69. # Set the user and group that the server normally runs at.
  70.  
  71. User nobody
  72.  
  73. Group nogroup
  74.   
  75. # Umask 022 is a good standard umask to prevent new files and dirs
  76.  
  77. # (second parm) from being group and world writable.

  78. Umask 022 022
  79.  
  80. PersistentPasswd off
  81.  
  82. MaxClients 8

  83. MaxClientsPerHost 8

  84. MaxClientsPerUser 8

  85. MaxHostsPerUser 8

  86. # Display a message after a successful login
  87.  
  88. AccessGrantMsg "welcome !!!"
  89.  
  90. # This message is displayed for each access good or not
  91.  
  92. 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 
 
 
 AllowUser userftp

 
 DenyALL 

 Umask 022 022 
 
 AllowOverwrite off 
 
 
 
 DenyAll 
 
 Umask 022 022 
 
 AllowOverwrite off 
 
 
 DenyAll 

 /home/FTP-shared/upload/>
 
 Umask 022 022 
 
 AllowOverwrite on    
 
 DenyAll 
 
 AllowAll


4- 启动/停止/重启动你的服务:

  1. sudo /etc/init.d/proftpd start
  2.  
  3. sudo /etc/init.d/proftpd stop
  4.   
  5. sudo /etc/init.d/proftpd restart
对你的proftpd进行一下语法检查:
  1. sudo proftpd -td5
想知道谁现在连接到你的服务,用ftptop命令(使用字母"t"来转换显示频率),你也可以使用"ftpwho"命令.


原文地址:


阅读(977) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~