免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2246 | 回复: 2
打印 上一主题 下一主题

[FTP] 使特定网段用户能自由上传下载的方法总结 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-08-12 11:11 |只看该作者 |倒序浏览
本人系菜鸟一个,前一段突发奇想做了以下的试验,现在问题解决了,把解决的方法总结一下,谨供参考,希望能给像我一样的菜鸟有所帮助。第一次写总结,总有如履薄冰,如临深渊的感觉,生怕误导别人。其中一定会有不妥或是错误,或者如果大家有什么更好的方法,希望大家提出来一起讨论。
解决过程中不少兄弟热情帮助尤其是wolfg斑竹的大力支持,十分感谢。

说明:在FC3上用vsftp实FTP服务。由于一些网段的用户为内部成员,不会对服务器造成危害。为了减少麻烦,更好地实现资源共享,现在想给他们的网段(本例中以10.0.1.*为例)的用户以自由上传下载的权利。

涉及的配置文件一共有四个:
vsftpd.conf
hosts.allow
/etc/vsftpd/local.class
/etc/vsftpd/other.class

内容:

hosts.allow
  1. #
  2. # hosts.allow        This file describes the names of the hosts which are
  3. #                allowed to use the local INET services, as decided
  4. #                by the '/usr/sbin/tcpd' server.
  5. vsftpd: 10.0.1.* : setenv VSFTPD_LOAD_CONF /etc/vsftpd/local.class
  6. vsftpd: ALL : setenv VSFTPD_LOAD_CONF /etc/vsftpd/other.class
复制代码


/etc/vsftpd/local.class
  1. write_enable=YES
  2. anon_upload_enable=YES
  3. anon_mkdir_write_enable=YES
复制代码


/etc/vsftpd/other.class
  1. write_enable=NO
  2. anon_upload_enable=NO
  3. anon_mkdir_write_enable=NO
复制代码


vsftpd.conf
  1. # Example config file /etc/vsftpd/vsftpd.conf
  2. #
  3. # The default compiled in settings are fairly paranoid. This sample file
  4. # loosens things up a bit, to make the ftp daemon more usable.
  5. # Please see vsftpd.conf.5 for all compiled in defaults.
  6. #
  7. # READ THIS: This example file is NOT an exhaustive list of vsftpd options.
  8. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
  9. # capabilities.
  10. #
  11. # Allow anonymous FTP? (Beware - allowed by default if you comment this out).
  12. anonymous_enable=YES
  13. #
  14. # Uncomment this to allow local users to log in.
  15. # 不允许本地用户上传下载,即只允许基于ip的认证
  16. #local_enable=YES
  17. #
  18. # Uncomment this to enable any form of FTP write command.
  19. # 在ftpd中的local.class和other.class文件中有write_enable=YES项
  20. #write_enable=YES
  21. #
  22. # Default umask for local users is 077. You may wish to change this to 022,
  23. # if your users expect that (022 is used by most other ftpd's)
  24. local_umask=022
  25. #
  26. # Uncomment this to allow the anonymous FTP user to upload files. This only
  27. # has an effect if the above global write enable is activated. Also, you will
  28. # obviously need to create a directory writable by the FTP user.
  29. #anon_upload_enable=YES
  30. #
  31. # Uncomment this if you want the anonymous FTP user to be able to create
  32. # new directories.
  33. #anon_mkdir_write_enable=YES
  34. #
  35. # Activate directory messages - messages given to remote users when they
  36. # go into a certain directory.
  37. dirmessage_enable=YES
  38. #
  39. # Activate logging of uploads/downloads.
  40. xferlog_enable=YES
  41. #
  42. # Make sure PORT transfer connections originate from port 20 (ftp-data).
  43. connect_from_port_20=YES
  44. #
  45. # If you want, you can arrange for uploaded anonymous files to be owned by
  46. # a different user. Note! Using "root" for uploaded files is not
  47. # recommended!
  48. #chown_uploads=YES
  49. #chown_username=whoever
  50. #
  51. # You may override where the log file goes if you like. The default is shown
  52. # below.
  53. xferlog_file=/var/log/vsftpd.log
  54. #
  55. # If you want, you can have your log file in standard ftpd xferlog format
  56. xferlog_std_format=YES
  57. #
  58. # You may change the default value for timing out an idle session.
  59. #idle_session_timeout=600
  60. #
  61. # You may change the default value for timing out a data connection.
  62. #data_connection_timeout=120
  63. #
  64. # It is recommended that you define on your system a unique user which the
  65. # ftp server can use as a totally isolated and unprivileged user.
  66. #nopriv_user=ftpsecure
  67. #
  68. # Enable this and the server will recognise asynchronous ABOR requests. Not
  69. # recommended for security (the code is non-trivial). Not enabling it,
  70. # however, may confuse older FTP clients.
  71. #async_abor_enable=YES
  72. #
  73. # By default the server will pretend to allow ASCII mode but in fact ignore
  74. # the request. Turn on the below options to have the server actually do ASCII
  75. # mangling on files when in ASCII mode.
  76. # Beware that turning on ascii_download_enable enables malicious remote parties
  77. # to consume your I/O resources, by issuing the command "SIZE /big/file" in
  78. # ASCII mode.
  79. # These ASCII options are split into upload and download because you may wish
  80. # to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
  81. # without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
  82. # on the client anyway..
  83. #ascii_upload_enable=YES
  84. #ascii_download_enable=YES
  85. #
  86. # You may fully customise the login banner string:
  87. #ftpd_banner=Welcome to blah FTP service.
  88. #
  89. # You may specify a file of disallowed anonymous e-mail addresses. Apparently
  90. # useful for combatting certain DoS attacks.
  91. #deny_email_enable=YES
  92. # (default follows)
  93. #banned_email_file=/etc/vsftpd.banned_emails
  94. #
  95. # You may specify an explicit list of local users to chroot() to their home
  96. # directory. If chroot_local_user is YES, then this list becomes a list of
  97. # users to NOT chroot().
  98. #chroot_list_enable=YES
  99. # (default follows)
  100. #chroot_list_file=/etc/vsftpd.chroot_list
  101. #
  102. # You may activate the "-R" option to the builtin ls. This is disabled by
  103. # default to avoid remote users being able to cause excessive I/O on large
  104. # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
  105. # the presence of the "-R" option, so there is a strong case for enabling it.
  106. #ls_recurse_enable=YES
  107. Anon_umask=022
  108. pam_service_name=vsftpd
  109. userlist_enable=YES
  110. #下面一行是我加的
  111. userlist_deny=YES
  112. #enable for standalone mode
  113. listen=YES
  114. tcp_wrappers=YES
复制代码


说明一下:
首先设置vsftpd.conf中tcp_wrappers=YES(一般的默认设置都是YES)。
当有用户访问时,则会自动查看hosts.allow的配置,而在根据hosts.allow中的语句,
系统会根据客户的IP跳转到不同的文件去,按照那里的设置工作。
在/etc/vsftpd/local.class中设置10.0.1.*网段的用户可以自由上传下载。
在/etc/vsftpd/other.class中设置其他用户只有下载的权限。
就是这么简单。不过有一点必须说明:那就是目录和文件的权限问题。
首先,设置你想让匿名用户上传的目录的可写权限
再一个在
vsftpd.conf中要加上
anon_umask=022
这一行是给匿名用户上传的文件添加可读的权限。你可以测试一下,匿名用户上传的文件的权限是600,即上传上去了却没有可读权限,下载不了!
Over!Good luck!

论坛徽章:
0
2 [报告]
发表于 2005-08-12 13:49 |只看该作者

使特定网段用户能自由上传下载的方法总结

鼓励!不过标题感觉不清楚

论坛徽章:
0
3 [报告]
发表于 2005-08-12 22:25 |只看该作者

使特定网段用户能自由上传下载的方法总结

哦,是吗。那应该怎样才更贴切呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP