rpm 搭建和配置vsftpd服务

实验环境:搭建ip192.168.1.128的ftp服务器

实验要求:1)匿名用户可以访问,访问根目录/tmp/var,只有查看和下载权限

                     2)本地用户可以访问,访问根目录必须是自己的宿主目录,具有完全控制权限。

1安装vsftpd服务

[[email protected] ~]
# yum install vsftpd* -y


Installed:
  vsftpd.i686 0:2.2.2-11.el6                                           

Complete!

2修改vsftpd.conf配置文件

[[email protected] ~]
# vim /etc/vsftpd/vsftpd.conf

1)匿名用户相关修改
anonymous_enable=YES

anon_root=/tmp/ftp   //修改匿名根目录

2)本地用户相关修改

local_enable=YES

write_enable=YES

local_umask=022

chroot_local_user=YES  //只允许用户访问自己的宿主目录

userlist_enable=no         //不开启userlist用户限制文件

3新建系统用户tom,密码redhat(用来测试)

[[email protected] ~]
# useradd tom

[[email protected] ~]
# passwd tom
更改用户 tom 的密码 。
新的 密码:
无效的密码: 它基于字典单词
无效的密码: 过于简单
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。

4启动vsftpd服务

[[email protected] ~]
# /etc/init.d/vsftpd start
为 vsftpd 启动 vsftpd:                                    [确定]
5查看端口是否开启

[email protected] ~]
# netstat -antp | grep vsftpd
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      1501/vsftpd  

6设为开机自启动服务


[[email protected] ~]
# chkconfig vsftpd on

7创建测试文件

# mkdir /tmp/ftp

[[email protected] /tmp]
# touch /tmp/ftp/1.mp3

[[email protected] /tmp]
# touch /home/tom/2.txt

8使用ftp客户端测试

#yum install ftp*

1)匿名登录测试:匿名用ftp连接,并且下载一个文件到/tmp下

[[email protected] /tmp]
# ftp 192.168.1.128
Connected to 192.168.1.128 (192.168.1.128).
220 (vsFTPd 2.2.2)
Name (192.168.1.128:root): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,1,128,22,65).
150 Here comes the directory listing.
-rw-r--r--    1 0        0               0 Mar 15 12:13 1.mp3
226 Directory send OK.
ftp> get 1.mp3 /tmp
local: /tmp remote: 1.mp3
227 Entering Passive Mode (192,168,1,128,84,167).
150 Opening BINARY mode data connection for 1.mp3 (0 bytes).
local: /tmp: 是一个目录
226 Transfer complete.
225 No transfer to ABOR.
ftp> get 1.mp3 /tmp/1.mp3
local: /tmp/1.mp3 remote: 1.mp3
227 Entering Passive Mode (192,168,1,128,90,111).
150 Opening BINARY mode data connection for 1.mp3 (0 bytes).
226 Transfer complete.

ftp> quit


2)使用tom用户登录测试,并且上传/tmp下的1.mp3到其宿主目录的ftp上

# ftp 192.168.1.128
Connected to 192.168.1.128 (192.168.1.128).
220 (vsFTPd 2.2.2)
Name (192.168.1.128:root): tom
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

ftp> ls
227 Entering Passive Mode (192,168,1,128,118,118).
150 Here comes the directory listing.
-rw-r--r--    1 0        0               0 Mar 15 12:06 2.txt
226 Directory send OK.
ftp> put /tmp/1.mp3
local: /tmp/1.mp3 remote: /tmp/1.mp3
227 Entering Passive Mode (192,168,1,128,27,62).
553 Could not create file.
ftp> cd /tmp/       
550 Failed to change directory    //只能在宿主目录,不能切换到其他目录
ftp> ls > upload.txt         //创建用于上传的测试文件
output to local-file: upload.txt?
227 Entering Passive Mode (192,168,1,128,108,161).
150 Here comes the directory listing.
226 Directory send OK.
ftp> put upload.txt
local: upload.txt remote: upload.txt
227 Entering Passive Mode (192,168,1,128,140,240).
150 Ok to send data.
226 Transfer complete.
ftp> ls
227 Entering Passive Mode (192,168,1,128,183,200).
150 Here comes the directory listing.
-rw-r--r--    1 0        0               0 Mar 15 12:06 2.txt
-rw-r--r--    1 500      500             0 Mar 15 12:26 upload.txt


















你可能感兴趣的:(LINUX)