Ubuntu vsftp配置

来源:互联网 发布:盘古网络唐山icp备 编辑:程序博客网 时间:2024/05/01 20:56
查看是否已经安装vsftp:
vsftpd -version

安装ftp:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install vsftp

检查ftp服务是否启动(登录ftp):
ftp localhost

启动ftp服务:
sudo service vsftpd start
关闭ftp服务:
sudo service vsftpd stop
重启ftp服务:
sudo service vsftpd restart
××××××××××××××××××××××××××××××××××
sudo /etc/init.d/vsftpd start
sudo /etc/init.d/vsftpd stop
sudo /etc/init.d/vsftpd restart

配置文件地址:sudo gedit /etc/vsftpd.conf
3.创建ftp用户
a,创建用户目录 sudo mkdir ~/FTP_Root
b,创建用户 sudo useradd -d ~/FTP_Root -s /bin/bash ubuntu_ftp
c,修改密码 sudo passwd ubuntu_ftp



配置实例:
# 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.
#
#
# 绑定到listen_port指定的端口,既然都绑定了也就是每时都开着的,就是那个什么standalone模式
listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
listen_ipv6=YES
#
# 是否允许匿名登录? (默认不允许).
anonymous_enable=YES
#匿名用户login时不询问口令
no_anon_password=YES
#
# 取消注释,则允许本地用户登录
local_enable=YES
#
# 允许使用任何可以修改文件系统的FTP的指令
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
#
# 是否允许匿名上传.
anon_upload_enable=NO
#
# 是否允许匿名创建文件夹.
anon_mkdir_write_enable=NO
#
# 允许为目录配置显示信息,显示每个目录下面的message_file文件的内容
dirmessage_enable=YES
#
# If enabled, vsftpd will display directory listings with the time
# in  your  local  time  zone.  The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=YES
#
# 是否启用记录日志.
xferlog_enable=YES
#
# 是否使用20端口传输数据
connect_from_port_20=YES

#可接受的最大client数目
max_clients=10
#
# 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
#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.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
#空闲连接超时
idle_session_timeout=600
#
#数据传输超时
data_connection_timeout=120
#
#PROT模式连接超时
connect_timeout=60
#
#当服务器运行于最底层时使用的用户名
#nopriv_user=ftpsecure
#
# 允许使用\"async ABOR\"命令,一般不用,容易出问题
#async_abor_enable=YES
#
# 管控是否可用ASCII 模式上传。默认值为NO
#ascii_upload_enable=YES
# 管控是否可用ASCII 模式下载。默认值为NO
#ascii_download_enable=YES
#
# login时显示欢迎信息.如果设置了banner_file则此设置无效
#ftpd_banner=Welcome to blah FTP service.
#
# 你可以指定一个不允许匿名电子邮件地址的文件。反对某些DoS攻击显然是有用的.
#deny_email_enable=YES
# (default follows)
# 禁止使用的匿名用户登陆时作为密码的电子邮件地址
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may restrict local users to their home directories.  See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# 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().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
# 如果启动这项功能,则所有列在chroot_list_file之中的使用者不能更改根目录
#chroot_list_enable=YES
# (default follows)
# 定义不能更改用户主目录的文件
#chroot_list_file=/etc/vsftpd.chroot_list
#
# 是否能使用ls -R命令以防止浪费大量的服务器资源
#ls_recurse_enable=YES
#
# 这个选项必须指定一个空的数据夹且任何登入者都不能有写入的权限,
# 当vsftpd 不需要file system 的权限时,就会将使用者限制在此数据夹中。
# 默认值为/usr/share/empty
secure_chroot_dir=/var/run/vsftpd/empty
#
#定义PAM 所使用的名称,预设为vsftpd
pam_service_name=vsftpd
#
# 这个选项的位置specifies的RSA证书使用SSL加密连接.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO

#使用utf8
utf8_filesystem=YES

#本地用户登录到ftp时的默认目录
local_root=/home/duke/FTP_Root/
 
#匿名用户登陆后的默认目录
anon_root=/home/duke/FTP_Root/anon








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

#若为YES,则userlist_file中的用户将不能登录,为NO则只有userlist_file的用户可以登录
userlist_deny=NO

#允许登录的用户
userlist_file=/etc/allowed_users
/etc/allowed_users文件(允许访问清单),添加创建的用户
/etc/ftpusers文件(不允许访问清单),删除创建的用户
***************************************

#可接受的最大client数目
max_clients=100
#使用标准的20端口来连接ftp
connect_from_port_20=YES
#PROT模式连接超时
connect_timeout=60
#数据传输超时
data_connection_timeout=120
#空闲连接超时
idle_session_timeout=600

#定义匿名登入的使用者名称。默认值为ftp。
ftp_username=FTP

#匿名用户login时不询问口令
no_anon_password=YES

#允许匿名用户登录
anonymous_enable=YES

#允许系统用户名登录
local_enable=YES

#允许使用任何可以修改文件系统的FTP的指令
write_enable=YES

#允许匿名用户上传文件
anon_upload_enable=NO

#充许匿名用户新建文件夹
anon_mkdir_write_enable=NO

#本地用户新增档案的权限
local_umask=022

#允许为目录配置显示信息,显示每个目录下面的message_file文件的内容
dirmessage_enable=YES

#本地用户登录到ftp时的默认目录
local_root=/home/duke/FTP_Root
 
#匿名用户登陆后的默认目录
anon_root=/var/ftp

#使用utf8
utf8_filesystem=YES

#添加允许登录的用户
sudo gedit /etc/allowed_users



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

如果启动这项功能,则所有列在chroot_list_file中的使用者不能更改根目录
#chroot_list_enable=YES

#chroot_list_file=/etc/vsftpd/chroot_list 定义不能更改用户主目录的文件
#ls_recurse_enable=YES    是否能使用ls -R命令以防止浪费大量的服务器资源
listen=YES  绑定到listen_port指定的端口,既然都绑定了也就是每时都开着的,就是那个什么standalone模式


#所有匿名上传的文件的所属用户将会被更改成chown_username
#chown_uploads=YES

#匿名上传文件所属用户名
#chown_username=whoever

#日志文件位置
#xferlog_file=/var/log/vsftpd.log
#开启日记功能
xferlog_enable=YES
#使用标准格式
xferlog_std_format=YES



0 0