CentOS7 下安装和配置本地用户登录VSFTP服务器

一、安装VSFTP

[plain]  view plain  copy
  1. # yum -y install vsftpd  
注意提升权限:

[plain]  view plain  copy
  1. #su root  

二、配置vsftpd.conf 文件

[plain]  view plain  copy
  1. [root@localhost ~]# vi /etc/vsftpd/vsftpd.conf  
  2.   
  3. # Example config file /etc/vsftpd/vsftpd.conf   
  4. #   
  5. # The default compiled in settings are fairly paranoid. This sample file   
  6. # loosens things up a bit, to make the ftp daemon more usable.   
  7. # Please see vsftpd.conf.5 for all compiled in defaults.   
  8. #   
  9. # READ THIS: This example file is NOT an exhaustive list of vsftpd options.   
  10. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's   
  11. # capabilities.   
  12. #   
  13. # Allow anonymous FTP? (Beware - allowed by default if you comment this out).   
  14. #anonymous_enable=YES  
  15. #   
  16. # Uncomment this to allow local users to log in.   
  17. local_enable=YES   
  18. #   
  19. # Uncomment this to enable any form of FTP write command.   
  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. # The target log file can be vsftpd_log_file or xferlog_file.   
  40. # This depends on setting xferlog_std_format parameter   
  41. xferlog_enable=YES   
  42. #   
  43. # Make sure PORT transfer connections originate from port 20 (ftp-data).   
  44. connect_from_port_20=YES   
  45. #   
  46. # If you want, you can arrange for uploaded anonymous files to be owned by   
  47. # a different user. Note! Using "root" for uploaded files is not   
  48. # recommended!   
  49. #chown_uploads=YES  
  50.   
  51. #chown_username=whoever   
  52. #   
  53. # The name of log file when xferlog_enable=YES and xferlog_std_format=YES   
  54. # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log   
  55. #xferlog_file=/var/log/xferlog   
  56. #   
  57. # Switches between logging into vsftpd_log_file and xferlog_file files.   
  58. # NO writes to vsftpd_log_file, YES to xferlog_file   
  59. xferlog_std_format=YES   
  60. #   
  61. # You may change the default value for timing out an idle session.   
  62. idle_session_timeout=600  
  63. #   
  64. # You may change the default value for timing out a data connection.   
  65. data_connection_timeout=120  
  66. # It is recommended that you define on your system a unique user which the   
  67. # ftp server can use as a totally isolated and unprivileged user.   
  68. #nopriv_user=ftpsecure   
  69. #   
  70. # Enable this and the server will recognise asynchronous ABOR requests. Not   
  71. # recommended for security (the code is non-trivial). Not enabling it,   
  72. # however, may confuse older FTP clients.   
  73. #async_abor_enable=YES   
  74. #   
  75. # By default the server will pretend to allow ASCII mode but in fact ignore   
  76. # the request. Turn on the below options to have the server actually do ASCII   
  77. # mangling on files when in ASCII mode.   
  78. # Beware that on some FTP servers, ASCII support allows a denial of service   
  79. # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd   
  80. # predicted this attack and has always been safe, reporting the size of the   
  81. # raw file.   
  82. # ASCII mangling is a horrible feature of the protocol.   
  83. ascii_upload_enable=YES  
  84. ascii_download_enable=YES  
  85.   
  86. #   
  87. # You may fully customise the login banner string:   
  88. ftpd_banner=Welcome to lightnear FTP service.  
  89. #   
  90. # You may specify a file of disallowed anonymous e-mail addresses. Apparently   
  91. # useful for combatting certain DoS attacks.   
  92. #deny_email_enable=YES   
  93. # (default follows)   
  94. #banned_email_file=/etc/vsftpd/banned_emails   
  95. #   
  96. # You may specify an explicit list of local users to chroot() to their home   
  97. # directory. If chroot_local_user is YES, then this list becomes a list of   
  98. # users to NOT chroot().   
  99. chroot_local_user=YES   
  100. #chroot_list_enable=YES   
  101. # (default follows)   
  102. #chroot_list_file=/etc/vsftpd/chroot_list   
  103. #   
  104. # You may activate the "-R" option to the builtin ls. This is disabled by   
  105. # default to avoid remote users being able to cause excessive I/O on large   
  106. # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume   
  107. # the presence of the "-R" option, so there is a strong case for enabling it.   
  108. ls_recurse_enable=YES  
  109. #   
  110. # When "listen" directive is enabled, vsftpd runs in standalone mode and   
  111. # listens on IPv4 sockets. This directive cannot be used in conjunction   
  112. # with the listen_ipv6 directive.   
  113. listen=YES   
  114. #   
  115. # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6   
  116. # sockets, you must run two copies of vsftpd with two configuration files.   
  117. # Make sure, that one of the listen options is commented !!   
  118. #listen_ipv6=YES  
  119.   
  120. pam_service_name=vsftpd   
  121. userlist_enable=YES   
  122. userlist_deny=NO   
  123. local_root=/var/public_root  
  124. tcp_wrappers=YES  
  125. use_localtime=YES  

三、增加FTP账号

[plain]  view plain  copy
  1. [root@localhost ~]# useradd ftpuser -s /sbin/nologin  
  2. [root@localhost ~]# passwd ftpuser  

ftpuser为账户名,passwd的作用为重设ftpuser的密码。


四、编辑user_list文件,允许FTPuser用户访问

[plain]  view plain  copy
  1. # vi /etc/vsftpd/user_list  
[plain]  view plain  copy
  1. # vsftpd userlist  
  2. # If userlist_deny=NO, only allow users in this file  
  3. # If userlist_deny=YES (default), never allow users in this file, and  
  4. # do not even prompt for a password.  
  5. # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers  
  6. # for users that are denied.  
  7. root  
  8. bin  
  9. daemon  
  10. adm  
  11. lp  
  12. sync  
  13. shutdown  
  14. halt  
  15. mail  
  16. news  
  17. uucp  
  18. operator  
  19. games  
  20. nobody  
  21. ftpuser  

五、建立我们的根目录,并设置访问权限

[plain]  view plain  copy
  1. # mkdir /var/public_root  
  2. # chown -R cent /var/public_root  
  3. # chmod -R 755 /var/public_root  

六、开启vsftpd服务

[plain]  view plain  copy
  1. # service vsftpd start  
  2. Starting vsftpd for vsftpd:                                [  OK  ]  

七、开启21端口

[plain]  view plain  copy
  1. #vi /etc/sysconfig/iptables   
在上面有行22 -j ACCEPT ,在下面照打一遍,但是把22改成21。改完之后,重启iptables。

[plain]  view plain  copy
  1. #service iptables restart   


八、修改selinux

[plain]  view plain  copy
  1. #getsebool -a | grep ftp   
执行上面命令,可以看到

[plain]  view plain  copy
  1. ....     
  2. allow_ftpd_full_access off     
  3. ....    
  4. ....    
  5. ftp_home_dir off   

将这两个权限都打开

[plain]  view plain  copy
  1. #setsebool -P allow_ftpd_full_access 1     
  2. #setsebool -P ftp_home_dir  1   
重启下vsftpd

[plain]  view plain  copy
  1. #service vsftpd restart   


设置成默认开启。
[plain]  view plain  copy
  1. # chkconfig vsftpd on  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值