With a bit of playing around I've managed to come up with a semi solution (not perfect but good enough)

using 2707974 answer and information I've gained else where I've been able to get what I need.

First you need vsftp and PAM installed

apt-get install vsftpd libpam-pwdfile

Edit /etc/vsftpd.conf

nano /etc/vsftpd.conf

then paste in the following

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
local_root=/var/www
chroot_local_user=YES
allow_writeable_chroot=YES
hide_ids=YES #virutal user settings
user_config_dir=/etc/vsftpd_user_conf
guest_enable=YES
virtual_use_local_privs=YES
pam_service_name=vsftpd
nopriv_user=vsftpd
guest_username=vsftpd

Edit to your exact needs the most important bit for virtual users is everything after the virtual user settings comment

Creating User

You can either use a database or htpasswd I found htpasswd faster and easier to use.

make a directory to store your users

mkdir /etc/vsftpd
htpasswd -cd /etc/vsftpd/ftpd.passwd user1

adding additional users just omit the -c

htpasswd -d /etc/vsftpd/ftpd.passwd user2

I've only managed to get it to work using CRYPT which limits to 8 chars to use more than 8 chars use openssl to generate a compatible hash and pipe directly into htpasswd

htpasswd -c -p -b /etc/vsftpd/ftpd.passwd user1 $(openssl passwd -1 -noverify password)

Once your users are created you can now change your PAM config file

nano /etc/pam.d/vsftpd

and remove everything inside this file and replace with the following

auth required pam_pwdfile.so pwdfile /etc/vsftpd/ftpd.passwd
account required pam_permit.so

This will enable login for your virtual users defined in /etc/vsftpd/ftpd.passwd and will disable local users

Next we need to add a user for these virtual users to use. These users will not have access to the shell and will be called vsftpd

useradd --home /home/vsftpd --gid nogroup -m --shell /bin/false vsftpd

the user must match guest_username=vsftpd in the vsftpd conf file

Defining Directory Access

The important line here is the following

user_config_dir=/etc/vsftpd_user_conf

this means that when user1 logs in it will look for the following file

/etc/vsftpd_user_conf/user1

this file the same as the vsftpd.conf so you can define a new local_root

going back to the question we want user1 to only have access to var/www/website_name1/sub_folder1, so we need to create the vsftpd_user_conf folder:

mkdir /etc/vsftpd_user_conf

Now create the user file:

nano /etc/vsftpd_user_conf/user1

and enter the following line

local_root=/var/www/website_name1/sub_folder1

Now restart vsftp

service vsftpd restart

you should now be able to login as user1 who will only be able to seevar/www/website_name1/sub_folder1 and any folder and file inside it.

That's it you can now add as many users as you want and limit their access to whatever folder you wish.

important to remember if you do not create a user conf file it will default to the var/www folder as root (in the example above)

If the subfolder is intended to be modifiable by the user, it might be necesary to change the owner of the shared subfolder:

chown vsftpd:nogroup /var/www/website_name1/sub_folder1

ubuntu vsftpd的更多相关文章

  1. ubuntu VSFTPD搭建FTP服务器 提示530错误

    配置完 vsftpd ,发现不能登录,提示 530 错误.解决方法如下: sudo rm /etc/pam.d/vsftpd 注:因为 ubuntu 启用了 PAM,所在用到 vsftp 时需要用到 ...

  2. 在 Ubuntu 16.04上安装 vsFTPd

    在 Ubuntu 16.04上安装 vsFTPd Ubuntu vsFTPd 关于 vsFTPd vsFTPd 代表 Very Secure File Transfer Protocol Daemon ...

  3. Ubuntu 12.04 LTS为例演示vsftpd虚拟用户 的配置

    vsftpd虚拟用户   2012-05-19 15:46:59|  分类: GNU/Linux |  标签:ubuntu  vsftpd  ftp  虚拟用户  |举报|字号 订阅 我们登录FTP有 ...

  4. vsftpd虚拟用户创建实例(转载)

    vsftpd虚拟用户创建实例 发布:theboy   来源:net     [大 中 小] vsftpd虚拟用户创建实例,有需要的朋友可以参考下.  vsftpd虚拟用户创建实例,有需要的朋友可以参考 ...

  5. ubuntu 包维护

    gnats == bug; tox = tales xillia ubuntu回显当前目录

  6. ubuntu 16.04 实现远程图形界面连接

    一.在操作系统中用管理员权限安装以下软件 1. 安装xrdp: sudo apt-get install xrdp 2. 安装vnc4server: sudo apt-get install vnc4 ...

  7. vsftp 虚拟用户高级设置(转载)

    发布:xiaokk   来源:net     [大 中 小] vsftp 虚拟用户高级设置  本文转自:http://www.jbxue.com/article/1724.html 1.安装所需软件包 ...

  8. Ubuntu 用vsftpd 配置FTP服务器

    网上的文章好难懂啊..只想要简单粗暴,弄好能用就行啊,复杂的以后研究不行吗...折腾好久,其实弄出来能用不就这么点内容吗... 本文在Ubuntu Server 14.04 amd64系统测试. Ma ...

  9. Ubuntu下使用vsftpd实现FTP

    ## 哈哈哈啊哈 被领导啪啪啪打脸,文件连在线打开都不行,你做事情的时候有没有考虑过别人使用时的感受!! 需求: 部门老大希望在内网搭建一个用于员工共享文件的系统. 很自然的就想到通过FTP去实现. ...

随机推荐

  1. 安装cartographer_ros

    这里使用的是hitcm(张明明)的github地址,由于google官方的教程需要FQ下载一些文件,因此容易失败,经验证hitcm(张明明)对原文件进行了少许修改后可以成功安装,在他的修改中核心代码不 ...

  2. package 'orocos-bfl' not found CMake Error at /usr/share/cmake-2.8/Modules/FindPkgConfig.cmake:283 (message):

    #没有数字 sudo apt-get install ros-indigo-bfl

  3. NIO 之 ByteBuffer

    前言 对于刚接触ByteBuffer人来说,想要完全理解会稍微有点困难,正巧前几天有人问我,想到好久没写文章,就整理一下. 概念理解 对于ByteBuffer的一些概念不理解的情况下,如果直接打开源码 ...

  4. 《剑指offer》第四十题(最小的k个数)

    // 面试题40:最小的k个数 // 题目:输入n个整数,找出其中最小的k个数.例如输入4.5.1.6.2.7.3.8 // 这8个数字,则最小的4个数字是1.2.3.4. #include < ...

  5. resin中关于url rewrite来传递jsessionid的问题

    最近两天在项目中碰到,一个很奇怪的问题.同一个账号多次切换登录时,会出现这个账号的信息在session中找不到,虽然可以登录成功,但是之后这个用户信息好像没有保存到session中一样,或者是被改变了 ...

  6. Java选择结构和数组

    Java选择结构和数组 一.Switch语句 二.if和switch区别 推荐使用if 三.函数 Java中的函数和方法是同一个词 四.数组 4.1.数组常见错误 五.内存机制 六.转换成十六进制 移 ...

  7. python-day8-赋值

    # x=10 #链式赋值# a=b=c=d=e=f=10# print(a,b,c,d,e,f) #增量赋值 # x=10# y='a'# temp=x# x=y# y=temp# print(x,y ...

  8. hdu 1024 最大M子段dp

    题目: Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  9. CodeForces 558B

    Description Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make ...

  10. Leetcode 17

    //狂练回溯,巧用备胎class Solution { public: vector<string> letterCombinations(string digits) { vector& ...