ubuntu vsftpd
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的更多相关文章
- ubuntu VSFTPD搭建FTP服务器 提示530错误
配置完 vsftpd ,发现不能登录,提示 530 错误.解决方法如下: sudo rm /etc/pam.d/vsftpd 注:因为 ubuntu 启用了 PAM,所在用到 vsftp 时需要用到 ...
- 在 Ubuntu 16.04上安装 vsFTPd
在 Ubuntu 16.04上安装 vsFTPd Ubuntu vsFTPd 关于 vsFTPd vsFTPd 代表 Very Secure File Transfer Protocol Daemon ...
- Ubuntu 12.04 LTS为例演示vsftpd虚拟用户 的配置
vsftpd虚拟用户 2012-05-19 15:46:59| 分类: GNU/Linux | 标签:ubuntu vsftpd ftp 虚拟用户 |举报|字号 订阅 我们登录FTP有 ...
- vsftpd虚拟用户创建实例(转载)
vsftpd虚拟用户创建实例 发布:theboy 来源:net [大 中 小] vsftpd虚拟用户创建实例,有需要的朋友可以参考下. vsftpd虚拟用户创建实例,有需要的朋友可以参考 ...
- ubuntu 包维护
gnats == bug; tox = tales xillia ubuntu回显当前目录
- ubuntu 16.04 实现远程图形界面连接
一.在操作系统中用管理员权限安装以下软件 1. 安装xrdp: sudo apt-get install xrdp 2. 安装vnc4server: sudo apt-get install vnc4 ...
- vsftp 虚拟用户高级设置(转载)
发布:xiaokk 来源:net [大 中 小] vsftp 虚拟用户高级设置 本文转自:http://www.jbxue.com/article/1724.html 1.安装所需软件包 ...
- Ubuntu 用vsftpd 配置FTP服务器
网上的文章好难懂啊..只想要简单粗暴,弄好能用就行啊,复杂的以后研究不行吗...折腾好久,其实弄出来能用不就这么点内容吗... 本文在Ubuntu Server 14.04 amd64系统测试. Ma ...
- Ubuntu下使用vsftpd实现FTP
## 哈哈哈啊哈 被领导啪啪啪打脸,文件连在线打开都不行,你做事情的时候有没有考虑过别人使用时的感受!! 需求: 部门老大希望在内网搭建一个用于员工共享文件的系统. 很自然的就想到通过FTP去实现. ...
随机推荐
- 雷林鹏分享:Ruby 安装 - Windows
Ruby 安装 - Windows 下面列出了在 Windows 机器上安装 Ruby 的步骤. 注意:在安装时,您可能有不同的可用版本. 下载最新版的 Ruby 压缩文件.请点击这里下载. 下载 R ...
- Java数组的定义和使用
如果希望保存一组有相同类型的数据,可以使用数组. 数组的定义和内存分配 Java 中定义数组的语法有两种: type arrayName[]; type[] arrayName; type 为Java ...
- 词向量-LRWE模型-更好地识别反义词同义词
上一节,我们介绍利用文本和知识库融合训练词向量的方法,如何更好的融合这些结构化知识呢?使得训练得到的词向量更具有泛化能力,能有效识别同义词反义词,又能学习到上下文信息还有不同级别的语义信息. 基于上述 ...
- mysql--------四种索引类型
一.索引的类型 mysql索引的四种类型:主键索引.唯一索引.普通索引和全文索引.通过给字段添加索引可以提高数据的读取速度,提高项目的并发能力和抗压能力.索引优化时mysql中的一种优化方式.索引的作 ...
- Session问题-一个部门A登录后未注销另一个部门B再登录,以B的身份操作A的成员
当管理员A登录后,打开某个管理界面.在A和B权限菜单相同的情况下,管理员B新开页面登录,session变为B的,然后切换到A打开的界面,不刷新的情况下可以操作A的数据. 解决方案:当浏览器登录后,即存 ...
- President's Path CodeForces - 416E (最短路,计数)
大意: 给定无向图, 求任意两点间所有最短路经过的边数 刚开始想先用floyd跑出最短路, 然后在DAG上DP, 交了1发, 发现会算重复 贴一下题解的做法 #include <iostream ...
- A Creative Cutout CodeForces - 933D (计数)
大意:给定$n$个圆, 圆心均在原点, 第$k$个圆半径为$\sqrt{k}$ 定义一个点的美丽值为所有包含这个点的圆的编号和 定义函数$f(n)$为只有$n$个圆时所有点的贡献,求$\sum_{k= ...
- 『PyTorch』第三弹重置_Variable对象
『PyTorch』第三弹_自动求导 torch.autograd.Variable是Autograd的核心类,它封装了Tensor,并整合了反向传播的相关实现 Varibale包含三个属性: data ...
- 『OpenCV3』简单图片处理
cv2和numpy深度契合,其图片读入后就是numpy.array,只不过dtype比较不常用而已,支持全部数组方法 数组既图片 import numpy as np import cv2 img = ...
- UVA-10061 How many zero's and how many digits ? (数论)
题目大意:让求n!在base进制下的位数以及末尾0的连续个数. 题目分析:一个m位的b进制数N,最小是b^(m-1),最大不超过b^m,即b^(m-1)≤N<b^m.解不等式,得log10(N) ...