VSFTP配置

适用范围:ReadHat与Centos系列。其它系统未经过测试过

1增加FTP账号

1.1新建一个FTP账号

adduser -s /sbin/nologin -d /ftpdirs/wjy  wjy

注:

-s /sbin/nologin            账号不可用于telnet、ssh登陆。

-d /ftpdirs/wjy             HOME目录,可不用事先建立。

 

1.2修改原有账号HOME目录

usermod -d /homedir wjy

注:

/homedir为wjy账号HOME目录

wjy为账号名称

1.3修改原有账号让账号无法用于telnet、ssh登陆

usermod -s /sbin/nologin wjy

注:

wjy为账号名称

1.4批量修改FTP账号密码

连同用户名密码一起写入文件.

[root@MGM2 vsftpd]# vi chpass.txt

zhaohang:123456

 

注:

格式为如下

账号:密码

 

使用如下命令对用户口令进行修改:

[root@MGM2 vsftpd]# chpasswd -e < chpass.txt

可以使用zhaohang账号,密码为 123456 来登录系统,密码修改完毕.

2修改FTP配置

2.1修改VSFTP配置

#vi /etc/vsftpd/vsftpd.conf

 

anonymous_enable=NO        #不接受匿名用户

local_enable=YES            #接受本地用户

write_enable=YES            #可以上传(全局控制)

local_umask=022             #本地用户上传文件的umask(创建文件权限)

dirmessage_enable=YES       #允许为目录配置显示信息

 

xferlog_enable=YES           #开启日记功能

connect_from_port_20=YES    #使用标准的20端口来连接ftp

 

xferlog_std_format=YES       #使用标准格式

 

chroot_list_enable=YES        #将FTP账号锁定在HOME目录

chroot_list_file=/etc/vsftpd/chroot_list    #将要锁定HOME目录的账号写入到这个文件中

#chroot_local_user=YES       #所有本地账号都不可以切换到主目录之外

listen=YES                  #绑定到listen_port指定的端口

listen_port=21              #绑定到某个端口(访问FTP用的端口)

 

pam_service_name=vsftpd      #定义PAM 所使用的名称,预设为vsftpd

userlist_enable=YES           #若启用此选项,userlist_deny选项才被启动

tcp_wrappers=YES            #开启tcp_wrappers支持

 

2.2将要锁定目录的账号添加到文件中

[root@MGM2 vsftpd]# vi /etc/vsftpd/chroot_list

sf_ftpuser

cd_ftpuser

dz_ftpuser

zg_ftpuser

my_ftpuser

ls_ftpuser

gy_ftpuser

ab_ftpuser

gz_ftpuser

 

注:每个账号占用一行

2.3重启VSFTP

修改完vsftpd.conf的参数需要重新启动VSFTP使配置生效,修改完/etc/vsftpd/chroot_list文件可以不用重启VSFTP

[root@MGM2 ~]# service vsftpd restart

 

3验证配置

Last login: Thu Aug 11 11:46:25 2011 from 192.168.6.166

[ccip@MGM2 ~]$

[ccip@MGM2 ~]$ su - wjy

Password:

This account is currently not available.

#提示此账号无法使用,验证此账号已无法用于telnetssh

[ccip@MGM2 ~]$

[ccip@MGM2 ~]$ ftp

ftp> open 192.168.123.17 2100

Connected to 192.168.123.17.

220 (vsFTPd 2.0.5)

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (192.168.123.17:ccip): wjy

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> pwd

257 "/"

ftp>

ftp> cd /usr

550 Failed to change directory.

ftp> cd /opt 

550 Failed to change directory.

#验证了此账号已无法切换到其它目录

ftp>

ftp> ls 

227 Entering Passive Mode (192,168,123,17,120,5)

150 Here comes the directory listing.

-rw-r--r--    1 528      528       0 Aug 11 03:21 hlrinfo.log

-rw-r--r--    1 0        0              13 Aug 11 05:42 test.txt

226 Directory send OK.

ftp> lcd /ftpdirs

Local directory now /ftpdirs

ftp>

ftp> put vsftp.txt   #上传文件进行验证

local: vsftp.txt remote: vsftp.txt

227 Entering Passive Mode (192,168,123,17,101,29)

150 Ok to send data.

226 File receive OK.

13 bytes sent in 5.7e-05 seconds (2.2e+02 Kbytes/s)

ftp> ls

227 Entering Passive Mode (192,168,123,17,168,122)

150 Here comes the directory listing.

-rw-r--r--    1 528      528          0 Aug 11 03:21 hlrinfo.log

-rw-r--r--    1 0        0              13 Aug 11 05:42 test.txt

-rw-r--r--    1 528      528            13 Aug 11 05:50 vsftp.txt

226 Directory send OK.

ftp> bye

221 Goodbye.

[root@MGM2 ftpdirs]# cd /wjy

[root@MGM2 wjy]# ll

total 8

-rw-r--r-- 1 wjy1 wjy1  0 Aug 11 11:21 hlrinfo.log

-rw-r--r-- 1 root root 13 Aug 11 13:42 test.txt

-rw-r--r-- 1 wjy1 wjy1 13 Aug 11 13:50 vsftp.txt

[root@MGM2 wjy]# cat vsftp.txt

Hello vsftp!

[root@MGM2 wjy]#

#/wjy目录中看到了上传文件,验证通过。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值