linux下FTP服务器添加本地用户

来源:互联网 发布:python tushare 安装 编辑:程序博客网 时间:2024/05/17 10:08

首先安装vsftpd服务,用yum安装即可:

 yum -y install vsftpd

vsftpd的主配置文件是/etc/vsftpd/vsftpd.conf

vi  /etc/vsftpd/vsftpd.conf

anonymous_enable=NO   ##设置是否允许虚拟用户登录,YES允许,NO禁止;

local_root=/home               ##设置本地用户的根目录;

添加以下两行:

chroot_list_enable=YES                                   #设置是否锁定用户在自己的主目录中;
chroot_list_file=/etc/vsftpd/chroot_list            #被列入该文件的用户,在登陆后锁定用户在自己的主目录中;

此时可以重启vsftpd服务了。

添加用户并设置密码:

useradd  zhangsan

passwd   zhangsan

设置密码为123456

并在张三的目录下创建个zhangsan.txt的文件。

touch /home/zhangsan.txt

在客户端测试ftp

[root@master home]# ftp 172.16.1.185
Connected to 172.16.1.185 (172.16.1.185).
220 (vsFTPd 2.2.2)
Name (172.16.1.185:root): zhangsan
331 Please specify the password.
Password:123456
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files. 
ftp> ls
227 Entering Passive Mode (172,16,1,185,214,27).
150 Here comes the directory listing.
drwx------    4 501      501          4096 Dec 03 14:05 houdy
drwx------    4 503      503          4096 Dec 03 16:52 zhangsan
226 Directory send OK.
ftp> cd houdy                                                                       ##用户zhangsan进入不到houdy这个用户的目录中;
550 Failed to change directory.
ftp> cd zhangsan                                                                #用户张三可以进入自己的目录内;
250 Directory successfully changed.
ftp> ls

227 Entering Passive Mode (172,16,1,185,169,128).

150 Here comes the directory listing.
-rw-r--r--    1 0        0               0 Dec 03 16:55 zhangsan.txt
226 Directory send OK.
ftp> 


0 0
原创粉丝点击