VSFTP安装配置之一
配置本地组访问的FTP
首先创建用户组 test和FTP的主目录
groupadd test
mkdir /tmp/test
然后创建用户
useradd -G test –d /tmp/test –M usr1
注:
G:用户所在的组;d:表示创建用户的自己目录的位置给予指定;M:不建立默认的自家目录,也就是说在/home下没有自己的目录
useradd –G test –d /tmp/test –M usr2
接着改变文件夹的属主和权限
chown usr1.test /tmp/test ----这表示把/tmp/test的属主定为usr1
chmod 750 /tmp/test ----7表示wrx 5表示rx 0表示什么权限都没有
这个实验的目的就是usr1有上传、删除和下载的权限,而usr2只有下载的权限没有上传和删除的权限,当然啦大家别忘了我们的主配置文件 vsftpd.conf,要确定local_enable=yes、write_enable=yes、chroot_local_usr=yes这三个选项是有的哦!
2. 配置独立FTP的服务器的非端口标准模式进行数据连接
这个非常容易:在VSFTPD.CONF中添加
Listen_port=33333
就可以了啦!
3. 配置单独的虚拟FTP,使用虚拟FTP用户,并使建立的四个帐户中有不同的权限
(两个有读目录的权限,一个有浏览、上传、下载的权限,一个有浏览、下载、删除和改文件名的权限)
A:配置网卡
第一块网卡地址是10.2.3.4 掩码是255.255.0.0
ifconfig eth0:1 211.131.4.253 netmask 255.255.255.0 up
B:写入/etc/sysconfig中(为了重起后IP地址不会丢失)
cd /etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-eth0:1
vi ifcfg-eth0:1在其中修改内容如下
DEVICE=eth0:1
BROADCAST=211.131.4.255
HWADDR=该网卡的MAC地址
IPADDR=211.131.4.253
NETMASK=255.255.255.0
NETWORK=211.131.4.0
onBOOT=yes
TYPE=Ethernet
wq推出
C:进入vsftpd.conf所在的文件夹
cp vsftpd.conf vsftpd2.conf
修改vsftpd.conf添加以下信息
Listen_address=10.2.3.4
修改vsftpd2.conf添加以下信息
Listen_address=211.131.4.253
Ftpd_banner=this is a virtual ftp test
到此虚拟的FTP服务器建立好了
D:建立logins.txt
vi /tmp/logins.txt
添加入下信息:
longlei------------用户名
longlei------------密码
zhangweibo
zhangweibo
jinhui
jinhui
lxp
lxp
格式要按照我的来哦,一个用户名,一个密码啦
F:建立访问者的口令库文件,然后修改其权限
db_load –T –t hash –f /tmp/logins.txt /etc/vsftpd_login.db
G:进如/etc/pam.d/中创建ftp.vu
在此文件中添加如下信息
auth required /lib/security/pam_userdb.so db=/etc/vsftpd_login
account required /lib/security/pam_userdb.so db=/etc/vsftpd_login
H:在/var/ftp/创建目录并改变其属性和它的属主
useradd -d /var/ftp/test qiang
chmod 700 /var/ftp/test
在目录中添加test_file测试文件
I:进入vsftpd2.conf修改其中的信息
Listen_yes
Anonymous_enable=no
Local_enable=yes
Write_enable=no
Anon_upload_enable=no
Anon_mkdir_write_enable=no
Anon_other_write_enable=no
Chroot_local_user=yes
Guest_enable=yes----------起用虚拟用户
Guest_username=qiang------将虚拟用户映射为本地用户
Listen_port=5555
Max_client=10
Max_per_ip=1
Ftpd_banner=this is a virtual server and users
Pam_service_name=ftp.vu
注:在主配置文件中给的权限越低,在后面分用户管理的时候对拥护的权限划分的空间就越大,因为主配置文件最高的限制服务先读主配置文件,然后再读用户的配置文件
重起服务,到此虚拟USER就建好了
J:在VSFTPD.CONF所在的目录中创建virtaul文件目录
并在文件目录中创建以你用户名命名的配置文件
Longlei zhangweibo jinhui lxp
在longlei中添加:
Anon_world_readable_only=no
在lxp中添加
Anon_world_readable_only=no
这样此两个用户就有了浏览目录的权限了
在jinhui中添加
Anon_world_readable_only=no
Write_enable=yes
Anon_upload_enable=yes
此用户就有了上传、下载和浏览的权限
在zhangweibo中添加
Anon_world_readable_only=no
Write_enable=yes
Anon_upload_enable=yes
Anon_other_write_enable=yes
此用户就有了上传、下载、删除文件目录、修改文件名和浏览的权限
K:修改vsftpd2.conf
加入user_config_dir=/vsftpd.conf所在的目录/virtual
重起服务器
下面是VSFTPD.CONF中的所有配置信息
Anonymous_enable=yes (允许匿名登陆)
Dirmessage_enable=yes (切换目录时,显示目录下.message的内容)
Local_umask=022 (FTP上本地的文件权限,默认是077)
Connect_form_port_20=yes (启用FTP数据端口的数据连接)*
Xferlog_enable=yes (激活上传和下传的日志)
Xferlog_std_format=yes (使用标准的日志格式)
Ftpd_banner=XXXXX (欢迎信息)
Pam_service_name=vsftpd (验证方式)*
Listen=yes (独立的VSFTPD服务器)*
Anon_upload_enable=yes (开放上传权限)
Anon_mkdir_write_enable=yes (可创建目录的同时可以在此目录中上传文件)
Write_enable=yes (开放本地用户写的权限)
Anon_other_write_enable=yes (匿名帐号可以有删除的权限)
Anon_world_readable_only=no (放开匿名用户浏览权限)
Ascii_upload_enable=yes (启用上传的ASCII传输方式)
Ascii_download_enable=yes (启用下载的ASCII传输方式)
Banner_file=/var/vsftpd_banner_file (用户连接后欢迎信息使用的是此文件中的相关信息)
Idle_session_timeout=600(秒) (用户会话空闲后10分钟)
Data_connection_timeout=120(秒) (将数据连接空闲2分钟断)
Accept_timeout=60(秒) (将客户端空闲1分钟后断)
Connect_timeout=60(秒) (中断1分钟后又重新连接)
Local_max_rate=50000(bite) (本地用户传输率50K)
Anon_max_rate=30000(bite) (匿名用户传输率30K)
Pasv_min_port=50000 (将客户端的数据连接端口改在Pasv_max_port=60000 50000—60000之间)
Max_clients=200 (FTP的最大连接数)
Max_per_ip=4 (每IP的最大连接数)
Listen_port=5555 (从5555端口进行数据连接)
Local_enble=yes (本地帐户能够登陆)
Write_enable=no (本地帐户登陆后无权删除和修改文件)
这是一组
Chroot_local_user=yes (本地所有帐户都只能在自家目录)
Chroot_list_enable=yes (文件中的名单可以调用)
Chroot_list_file=/任意指定的路径/vsftpd.chroot_list (前提是chroot_local_user=no)
这又是一组
Userlist_enable=yes (在指定的文件中的用户不可以访问)
Userlist_deny=yes
Userlist_file=/指定的路径/vsftpd.user_list
又开始单的了
Banner_fail=/路径/文件名 (连接失败时显示文件中的内容)
Ls_recurse_enable=no
Async_abor_enable=yes
one_process_model=yes
Listen_address=10.2.2.2 (将虚拟服务绑定到某端口)
Guest_enable=yes (虚拟用户可以登陆)
Guest_username=所设的用户名 (将虚拟用户映射为本地用户)
User_config_dir=/任意指定的路径/为用户策略自己所建的文件夹 (指定不同虚拟用户配置文件的路径)
又是一组
Chown_uploads=yes (改变上传文件的所有者为root)
Chown_username=root
又是一组
Deny_email_enable=yes (是否允许禁止匿名用户使用某些邮件地址)
Banned_email_file=//任意指定的路径/xx/
又是单的
Pasv_enable=yes ( 服务器端用被动模式)
User_config_dir=/任意指定的路径//任意文件目录 (指定虚拟用户存放配置文件的路径)
 
 
VSFTP安装配置之二
查看是否安装了vsFTPd软件
[root@mysrv root]# rpm -qa | grep vsftpd
如果没有任何显示,说明没有把vsFTPd安装上,如果出现的是下面的这样的提示,就证明已经安装上了。
[root@mysrv root]# rpm -qa | grep vsftpd
vsftpd-1.1.3-8
Redhat 9.0,以其自带的vsFTPd包vsftpd-1.1.3-8版本
二。如果没有装安.从updates.redhat.com下载vsftp的rpm包
ftp updates.redhat.com
提示ftp用户是用anonymous用户密码任意输入几个字符在/9/en/os/i386/目录下可以找一vsftpd-1.1.3-8.i386.rpm,用get 下载到安装服务器(注意不同版本的Linux不同)
三。 安装vsftpd
直接运行命令    rpm -Uvh vsftpd-1.1.3-8.i386.rpm
四。打开vsFTPd服务让它系统启动时自动启动服务。
[root@mysrv root]# ntsysv
把vsftpd服务设置为启动,也就是在运行 ntsysv命令后,把vsftpd服务选中。
vsftpd
手动停启vsftpd服务命令如下
/etc/rc.d/init.d/vsftpd stop 停[或者(service vsftp stop)]
/etc/rc.d/init.d/vsftpd start 启[或者(service vsftp start)]
五。配制vsFTPd,vsFTPd的运行模式并去除匿名FTP及限定FTP帐号的目录。
vsFTPd的运行模式有二种,一种是standalone "initd"模式,另外一种是xinetd模式,对我们应该设置为standalone "initd"运行模式。
1 把vsFTPd的配制文件改一下就行了。vi /etc/vsftpd/vsftpd.conf。找到#enable for standalone mode,把#去掉,保存并/etc/rc.d/init.d/vsftpd reload
刷新一下vsftpd的设置
两种模式运行机制不是相同的,stardard initd模式,适合专业FTP,且FTP总是一直有人访问,占用资源也是比较大,如果您的FTP总是有人访问和登入。就要用这种模式。如果您的FTP访问人数比较小,建议您用xinetd模式。xinetd模式,是当用户请求时,vsFTPd才会启动。
2 把vsFTPd的配制文件改一下就行了。配制文件在/etc/vsftpd/vsftpd.conf,用vi 编辑器打开。
找到anonymous_enable=Yes 改为anonymous_enable=No ,保存并/etc/rc.d/init.d/vsftpd reload 涮新一下vsftpd的设置
如果我们想把用户目录定位到别的目录应该怎么办呢??这个也比较简单,看一下useradd就比较明白了。比如我想添加beinan这个用户,并把目录放在/opt目录中:如下操作:
3 限定vsFTP目录就要给FTP帐号建chroot。
vi /etc/vsftpd/vsftpd.conf 找到
#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd.chroot_list
把#去掉,保存并/etc/rc.d/init.d/vsftpd reload 涮新一下vsftpd的设置
同时在etc目录下建vsftpd.chroot_list文件,在vsftpd.chroot_list文件内录入FTP帐号用户名,注意:每个FTP帐号用户名一行
修改前vsftpd.conf
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are very paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
#
# Allow anonymous FTP?
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
#
# 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
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# 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
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
#
# 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
#
# 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
#
# 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 turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command "SIZE /big/file" in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# 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
pam_service_name=vsftpd
userlist_enable=YES
#enable for standalone mode
listen=YES
tcp_wrappers=YES

修改后的vsftpd.conf
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are very paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
#
# Allow anonymous FTP?
anonymous_enable=No
#
# 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
#
# 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
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# 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
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
#
# 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
#
# 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
#
# 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 turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command "SIZE /big/file" in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# 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
pam_service_name=vsftpd
userlist_enable=YES
enable for standalone mode
listen=YES
tcp_wrappers=YES