zoukankan      html  css  js  c++  java
  • 008.FTP单独虚拟用户

    一 单独虚拟用户概念

    给每个虚拟用户单独建立目录,并建立自己的配置文件,方便单独配置权限,并可以单独制定上传目录。

    二 单独为虚拟用户设置权限

    2.1 创建用户单独保存虚拟用户配置文件的目录

      1 [root@imxhy ~]# mkdir /etc/vsftpd/vusers_dir		#创建配置文件保存目录

    注意:1 此为目录,非文件,单独保存了虚拟用户的配置文件

    2.2 添加配置项

      1 [root@imxhy ~]# vi /etc/vsftpd/vsftpd.conf
      2 local_root=/home/vftproot/				#用于其他用户继承的主目录
      3 user_config_dir=/etc/vsftpd/vusers_dir		#指定保存虚拟用户配置文件的目录

    注意:1 如没有给虚拟用户单独指定配置文件,则默认继承主配置文件vsftpd.conf的配置

    2.3 单独创建配置文件

      1 [root@imxhy vusers_dir]# cd /etc/vsftpd/vusers_dir/
      2 [root@imxhy vusers_dir]# vi ftptest01			#单独的配置文件名必须和虚拟用户名一致
      3 anon_upload_enable=YES
      4 anon_mkdir_write_enable=YES
      5 anon_other_write_enable=YES				#允许此用户上传
      6 local_root=/home/ftptest01				#指定独立的上传目录

    2.4 创建虚拟用户主目录并修改权限

      1 [root@imxhy ~]# mkdir /home/ftptest01		        #创建独立的目录
      2 [root@imxhy ~]# chown vuser /home/ftptest01/
      3 #能否上传需要FTP服务权限,同时也需要上传目录的权限,因此需要将主目录所属人修改为本地用户vuser
      4 [root@imxhy ~]# chmod u-w /home/ftptest01/
      5 #新版vsftp不允许对主目录有w权限,否则无法登录,取消w权限。
      6 [root@imxhy ~]# mkdir /home/ftptest01/pub		        #创建用户可上传的目录
      7 [root@imxhy ~]# chown vuser:vuser /home/ftptest01/pub/	#将所属人改为vuser
      8 [root@imxhy ~]# ll /home/
      9 ……
     10 dr-xr-xr-x. 2 vuser    root        6 Aug 30 06:56 ftptest01
     11 [root@imxhy ~]# ls -ld /home/ftptest01/pub/
     12 drwxr-xr-x. 2 vuser vuser 6 Aug 30 07:15 /home/ftptest01/pub/
     13 [root@imxhy ~]# systemctl restart vsftpd
     14 [root@imxhy ~]# cd /home/ftptest01/
     15 [root@imxhy ftptest01]# touch down.txt			#创建用户测试文件

    三 测试登陆

      1 E:Tempftp>ftp 192.168.10.10
      2 连接到 192.168.10.10。
      3 220 (vsFTPd 3.0.2)
      4 用户(192.168.10.10:(none)): ftptest01
      5 331 Please specify the password.
      6 密码:
      7 230 Login successful.
      8 ftp> get down.txt
      9 200 PORT command successful. Consider using PASV.
     10 150 Opening BINARY mode data connection for down.txt (0 bytes).
     11 226 Transfer complete.
     12 ftp> put down.txt
     13 200 PORT command successful. Consider using PASV.
     14 553 Could not create file.				#主目录不允许上传
     15 ftp> cd pub
     16 250 Directory successfully changed.
     17 ftp> put down.txt
     18 200 PORT command successful. Consider using PASV.
     19 150 Ok to send data.
     20 226 Transfer complete.					#子目录下可上传

    四 总结

    • 没有单独指定配置文件主目录的默认继承主配置文件文件配置
    • vsft安全限制,禁止在任何主目录下上传文件,必须新建一层子目录,然后赋予所属人为vuser
  • 相关阅读:
    左偏树
    论在Windows下远程连接Ubuntu
    ZOJ 3711 Give Me Your Hand
    SGU 495. Kids and Prizes
    POJ 2151 Check the difficulty of problems
    CodeForces 148D. Bag of mice
    HDU 3631 Shortest Path
    HDU 1869 六度分离
    HDU 2544 最短路
    HDU 3584 Cube
  • 原文地址:https://www.cnblogs.com/itzgr/p/9890938.html
Copyright © 2011-2022 走看看