rpm 搭建和配置vsftpd服务

来源:互联网 发布:python可以跨平台吗 编辑:程序博客网 时间:2024/05/16 19:42

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

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

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

1安装vsftpd服务

[root@localhost.localdomain ~]
# yum install vsftpd* -y


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

Complete!

2修改vsftpd.conf配置文件

[root@localhost.localdomain ~]
# 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(用来测试)

[root@localhost.localdomain ~]
# useradd tom

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

4启动vsftpd服务

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

root@localhost.localdomain ~]
# netstat -antp | grep vsftpd
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      1501/vsftpd  

6设为开机自启动服务


[root@localhost.localdomain ~]
# chkconfig vsftpd on

7创建测试文件

# mkdir /tmp/ftp

[root@localhost.localdomain /tmp]
# touch /tmp/ftp/1.mp3

[root@localhost.localdomain /tmp]
# touch /home/tom/2.txt

8使用ftp客户端测试

#yum install ftp*

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

[root@localhost.localdomain /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


















0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 属猴的人养猫怎么办 对方电话拉黑我怎么办 手机号码换了淘宝账号怎么办 扣扣号有密码无法加好友怎么办 扣扣帐号忘记了怎么办 扣扣帐号被冻结怎么办 xp忘了开机密码怎么办 手机怎样知道好友qq密码怎么办 找回微信密码申诉失败怎么办 若微信号被盗钱怎么办 微信号被倒了怎么办 微信支付密码忘了怎么办 微信钱包密码忘了怎么办 忘记qq锁屏密码怎么办 微信里保密柜密码忘记了怎么办 qq漫游记录密码忘了怎么办 当你很烦的时候怎么办 当你烦的时候怎么办 面对刁蛮不讲理的老婆怎么办 老是想以前的事怎么办 被心机婊陷害了怎么办 分手了还被骚扰怎么办 苹果手机屏幕出现冷暖屏怎么办 我感觉媳妇不漂亮怎么办 90后赚不到钱怎么办 处对象感觉好累怎么办 谈朋友感觉好累怎么办 家庭条件不好娶老婆难办怎么办? 异地恋闹矛盾了怎么办 有人威胁要杀我全家怎么办 分手了借我的钱怎么办 脸打架打肿了怎么办 人家不加我qq好友怎么办 一个好友被删了怎么办 dnf脸黑怎么办还有办法 我想登别人微信怎么办 昌硕工资没到怎么办 昌硕离职不批怎么办 昌硕工资不到卡怎么办 上海人去苏州工作社保怎么办 娶个个脾气暴躁的媳妇怎么办