vsftpd的安装和使用

1.安装
#cd /usr/ports/ftp/vsftpd  && make install clean
2.运行vsftpd
#vi /usr/local/etc/vsftpd.conf
在里面加入一句listen=YES   保存后退出
#adduser ftp   <----建立ftp用户
#chown root:ftp /home/ftp  <---------给/home/ftp目录赋予权限
#chmod 755 /home/ftp    <------同上
#/usr/local/libexec/vsftpd /usr/local/etc/vsftpd.conf &
如果不出意外 vsftpd就已经在运行了
# netstat -an | grep 21
tcp4       0      0  *.21                   *.*                    LISTEN       <------可以看到21端口已经打开了
现在可以登陆试一下
# ftp 127.0.0.1
Connected to 127.0.0.1.
220 (vsFTPd 2.0.6)
Name (127.0.0.1:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||9778|)
150 Here comes the directory listing.
-rw-r--r--    1 0        0        159207965 Dec 07 06:59 1.rmvb
-rw-r--r--    1 0        1001         2649 Jan 11 05:41 xorg.conf.new
226 Directory send OK.

现在一般应用已经建好了
3.扩展应用
下面是我的vsftpd.conf文件
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES  <-----是否允许匿名登陆  你如果选否的话 只须把此命令注释掉即可 下同
#
# Uncomment this to allow local users to log in.
#local_enable=YES  <--------是否允许本地用户登陆
#
# Uncomment this to enable any form of FTP write command.
#write_enable=YES   <------是否允许本地用户写的权限
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#local_umask=022  <-----ftp server 上文件的权限
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES   <-------是否允许上传的权限
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES   <-----是否允许创建目录并在此目录上传文件
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES   <----切换目录时,显示目录下.message的内容
#
# Activate logging of uploads/downloads.
xferlog_enable=YES  <--------是否允许上传和下载时显示日志
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES    <-------FTP数据端口的数据连接
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES   <-----改变上传文件的所有者为root
#chown_username=whoever   
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log    <----日志目录
#
# If you want, you can have your log file in standard ftpd xferlog format
#xferlog_std_format=YES   <-----使用标准的日志格式
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600   < --------- 空闲数据连接的中断时间

# You may change the default value for timing out a data connection.
#data_connection_timeout=120   <---没有数据传输的话  2分钟断
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure  <-------- 运行vsftpd需要的非特殊系统用户
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES  <-------- 是否允许运行特殊的FTP命令async
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES   <---------是否启用ASCII的上传传输
#ascii_download_enable=YES   <---------是否启用ASCII的下载传输
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.   <------欢迎信息
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES   <-----是否允许禁止匿名用户使用某些邮件地址
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES  <---------是否可以调用文件中的名单
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES   〈----- 是否允许使用“ls”命令
listen=YES
secure_chroot_dir=/usr/local/share/vsftpd/empty

理解了上面的配置选项  再配置起来就不复杂了
比如我要建立一个wang的用户有上传和下载的权限
编辑vsftpd.conf找到
#local_enable=YES
#write_enable=YES 把注释去掉 重起服务器
再建一个wang的用户  客户端就可以wang 用户登陆了
C:/>ftp 192.168.1.4
Connected to 192.168.1.4.
220 (vsFTPd 2.0.6)
User (192.168.1.4:(none)): wang
331 Please specify the password.
Password:
230 Login successful.
ftp> bin
200 Switching to Binary mode.
ftp> put lame.exe
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 发送 153088 字节,用时 0.02Seconds 9568.00Kbytes/sec.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
index
lame.exe
226 Directory send OK.
ftp: 收到 17 字节,用时 0.00Seconds 17000.00Kbytes/sec.
ftp> del lame.exe
250 Delete operation successful.

今天先到着 闲了我还会把建立虚拟用户的过程发上来 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值