FTP installation under Debian

Reprinted from: http://blog.csdn.net/rainysia/article/details/7987459

1: Install vsftpd

#aptitude install vsftpd

 

2: Configure vsftpd

#vim /etc/vsftpd.conf

 

[cpp]  view plain  copy
 
  1. # The server runs in standalone mode, so that the following controls can be performed  
  2. listen=YES  
  3. # accept anonymous users  
  4. anonymous_enable=YES  
  5. # Do not ask for password when an anonymous user logs in  
  6. no_anon_password=YES  
  7. # accept local users  
  8. local_enable=YES  
  9. # Can upload (global control). If you want anonymous users to upload, you need to set anon_upload_enable=YES,   
  10. # If you want anonymous users to create directories, you need to set anon_mkdir_write_enable=YES. Here, anonymous users are prohibited from uploading, so these two items are not set  
  11. write_enable=YES  
  12. # The umask of the file uploaded by the local user  
  13. local_umask=022  
  14. # If set to YES, anonymous logins will be allowed to upload directory permissions, of course, anonymous users must have the right  
  15. # Write permission for the layer directory.  
  16. anon_upload_enable=YES  
  17. # Define the username for anonymous login. Default is ftp  
  18. ftp_username=ftp  
  19. # If set to YES, anonymous logins will be allowed to add directories. Of course, anonymous users must have access to the upper directory  
  20. # write rights.  
  21. anon_mkdir_write_enable=YES  
  22. # For YES, when entering the directory, display the text file specified by the message_file option in this directory  
  23. # (, defaults to the content of .message)  
  24. dirmessage_enable=YES  
  25. # The directory where the local user is after logging in. If this item is not set, the local user will be in his home directory after logging in.  
  26. # (/etc/passwd的第六个字段)中.匿名用户的对应选项是anon_root  
  27. # local_root=/home  
  28. anon_root=/home/ftp/  
  29. # 使用上传/下载日志,日志文件默认为/var/log/vsftpd.log,可以通过xferlog_file  
  30. # 选项修改  
  31. xferlog_enable=YES  
  32. # Make sure PORT transfer connections originate from port 20 (ftp-data).  
  33. connect_from_port_20=YES  
  34. # 日志使用标准xferlog格式  
  35. xferlog_std_format=YES  
  36. # You may change the default value for timing out a data connection.  
  37. data_connection_timeout=120  
  38. # 关闭本地用户chroot()  
  39. chroot_local_user=NO  
  40. # 设置为yes则下面的控制有效。  
  41. # 开启要设置chroot()用户项.  
  42. chroot_list_enable=YES  
  43. # (default follows)  
  44. # 指定要设置chroot()的特定用户文件  
  45. chroot_list_file=/etc/vsftpd.chroot_list  
  46. # 若设置为YES则记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)  
  47. # 中的用户无法login,并且将检察下面的userlist_deny选项  
  48. userlist_enable=YES  
  49. # 若为NO,则仅接受记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)  
  50. # 中的用户的login请求.若为YES则不接受这些用户的请求.  
  51. userlist_deny=NO  
  52. # 注意!!!vsftpd还要检察/etc/vsftpd.ftpusers文件,记录在这个文件中的用户将  
  53. # 无法login!!  
  54. # 匿名用户的传输比率(b/s)  
  55. anon_max_rate=512000  
  56. # 本地用户的传输比率(b/s)  
  57. local_max_rate=1024000  
  58. # 可接受的最大client数目  
  59. max_clients=100  
  60. # 每个ip的最大client数目  
  61. max_per_ip=5  
  62. # This option should be the name of a directory which is empty.  Also, the  
  63. # directory should not be writable by the ftp user. This directory is used  
  64. # as a secure chroot() jail at times vsftpd does not require filesystem access.  
  65. secure_chroot_dir=/var/run/vsftpd  
  66. # This string is the name of the PAM service vsftpd will use.  
  67. pam_service_name=vsftpd  
  68.   
  69. tcp_wrappers=YES  
  70.   
  71. # This option specifies the location of the RSA certificate to use for SSL  
  72. # encrypted connections.  
  73. rsa_cert_file=/etc/ssl/certs/vsftpd.pem  
  74. # 每一个联机,都能以独立的process 来呈现.  
  75. setproctitle_enable=YES  
  76. # 若是启动,所有匿名上传数据的拥有者将被更换为chown_username当中所设定的使用  
  77. # 者。这样的选项对于安全及管理,是很有用的。  
  78. chown_uploads=YES  
  79. # 这里可以定义当匿名登入者上传档案时,该档案的拥有者将被置换的使用者名称。预  
  80. # 设值为root。  
  81. chown_username=root  

 

3: 增加用户名 用户组

#groupadd ftpuser

#mkdir /home/tom/

#useradd -g ftpuser tom

passwrd tom

 

4:修改权限

#vim /etc/passwd

最后面是权限

tom:x:1001:1001::/home/tom:

增加/bin/bash

tom:x:1001:1001::/home/tom:/bin/bash

更改文件所有者权限

#chown -v -R tom:ftpuser /home/tom/

#chmod -v -R 700 /home/tom/

共享给ftpuser组一个文件夹,做一个连接

#ln -v -s /home/ftpuser/ /home/tom/ftpuser

设置欢迎信息,在每个用户的文件夹中新建.message

编辑/etc/vsftpd.user_list 填写所有ftp的用户,包括匿名的anonymous

编辑/etc/vsftpd.chroot_list 填写不准进入上层目录的用户名

给/home/ftp/ 中允许匿名写的目录的修改权限,没有新建

保存后重启vsftpd

#/etc/init.d/vsftpd restart

chmod -v 777 /home/ftp/temp/

 

5. vsftpd的log默认在/var/log/vsftpd.log 

ftp的目录在/home/ftp

 

如果用户登录报错530 

那么检查下/etc/passwd 的shell,改为/sbin/ nologin

并且在 /etc/shell里面加入上面的地址 保存后重启vsftpd

要挂载非ftp的目录,比如其他的路径,使用mount --bind

比如要挂在/home/music 到/home/ftp/music  先mkdir /home/ftp/music

#mount --bind /home/music /home/ftp/music

Just

If you need to automatically mount after restart, you need to modify /etc/fstab

Add the device name, mount point, filessystem, options that need to be mounted

Or directly add the mount command in /etc/rc.local to let it mount automatically when it starts up 

 

[php]  view plain  copy
 
  1. mount --bind /home/media/ /home/ftpuser/media/  
  2. mount --bind /home/manual/ /home/ftpuser/manual/  
  3. mount --bind /home/tools/ /home/ftpuser/software/  

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326655453&siteId=291194637