CenOS6.0配置vsftp

1. 查看是否安装vsftpd ftp

rpm -qa| grep vsftpd

没有装过的话,使用yum安装

yum -y install vsftpd

以同样的方法,看是否安装ftp,(安装ftp是为了在本机测试用的)
2. 修改配置文件/etc/vsftpd/vsftpd.conf 

vim /etc/vsftpd/vsftpd.conf

没有安装vim的,使用vi是一样的。这里根据自己的需要进行配置,参考(http://www.cnblogs.com/rooney/archive/2009/03/14/1411620.html 这个网址的,很详细)

这里就不详细说明了 贴上自己设置的 (由于还是菜鸟级别 勿拍 写这个的主要目的是怕自己忘了 呵呵)

# Example config file /etc/vsftpd/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
no_anon_password=YES
allow_anon_ssl=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
anon_other_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.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
idle_session_timeout=300
#
# You may change the default value for timing out a data connection.
data_connection_timeout=60
#
# 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=binger
#
# 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 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_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_local_user=YES
chroot_list_enable=NO

# (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=NO
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
guest_enable=YES
guest_username=bbftp
virtual_use_local_privs=YES
user_config_dir=/etc/vsftpd/vuser_conf
max_clients=1

3.如果有虚拟用户的话,创建虚拟用户目录(用户名,密码)

vim /etc/vsftpd/vftpuser

里面一行用户名,一行密码就好了,如

binger

123456

即:用户名:binger,密码:123456

4.生成用户数据库文件,比如虚拟用户需要输入用户名密码的,以此数据库为验证  及验证

方法一:使用数据库db4

 a. 查看db4-utils是否安装

    方法与产看vsftpd是否安装一样,没有安装的话,使用yum安装

 b. 生成数据库文件

db_load -T -t hash -f /etc/vsftpd/vsftpuser /etc/vsftpd/vsftpuser.db

 c. 验证

    确定安装了pam,pam-devel,然后:   

vim /etc/pam.d/vsftpd

    32位系统增加以下两句:

         auth      required     pam_userdb.so db=/etc/vsftpd/vftpuser

         account   required     pam_userdb.so db=/etc/vsftpd/vftpuser

    64位系统增加以下两句:

          auth   required    /lib64/security/pam_userdb.so db=/etc/vsftpd/vftpuser

          account required    /lib64/security/pam_userdb.sodb=/etc/vsftpd/vftpuser

如果不需要本地用户验证的,可以把其他内容都注释掉

方法二:使用mysql数据库配置与验证

   参考(http://shellfish.iteye.com/blog/358764

   因为没有试验过,所以...所以...

5. 创建虚拟账户所要映射的本地用户(如果只需匿名登录的话,可guess_enable等几个设置注释掉就好,可以跳到7)

  以本例为例:创建bbftp用户,并设定其主文件夹的位置为/var/ftp 

useradd -d /var/ftp bbftp

6.如果设定了每个虚拟用户自己的配置文件的话,则创建每个虚拟用户的配置文件

   在vsftpd中设定的目录为/etc/vsftpd/vuser_conf

    然后在这个文件夹下建立一虚拟用户名命名的文件,里面的配置信息,参照vsftpd中的相关设置选项就好

7. 修改上传文件夹的权限

  如本例中指定的为/var/ftp文件夹,则可以在里面建立两个文件夹 public 和upload

  其中设置upload的权限为777,用户可以修改、删除、上传、下载文件,而public的权限为755,则在其中只能下载文件。同样的权限设置给ftp文件夹,修改权限的命令:

cd /var/ftp
mkdir upload
chmod 777 upload

8. 对于SELinux,iptables的设置
  ==>iptables修改,修改了iptables之后,就可以不用关闭selinux

  a. 可以直接编写/etc/sysconfig/iptables,但是每次在setup里面设置防火墙之后,貌似都会改变,所以最好是写在iptables.save中

-A INPUT -m state --state NEW -m tcp -p tcp --dport 20 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT

  注意,这规则最好加在下面三行下面另起一行,不要加在最后

-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT  
-A INPUT -p icmp -j ACCEPT    
-A INPUT -i lo -j ACCEPT 

  b. 也可以在终端输入setup,然后再图形化界面中修改-->防火墙设置-->定制-->选中ftp

  c. 也可以

sudo /etc/rc.d/init.d/iptables stop
sudo /sbin/iptables -I INPUT -p tcp --dport 20 -j ACCEPT
sudo /sbin/iptables -I INPUT -p tcp --dport 21 -j ACCEPT
sudo /etc/rc.d/init.d/iptables save 
sudo /etc/rc.d/init.d/iptables start

 ==>可以关掉SELINUX,在/etc/selinux/config 配置文件如下;

vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=Disabled  #这样就把SELINUX服务器关掉了,请重新启动系统;
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

9. 对于建立虚拟目录,指定用户在自己文件夹内修改等,都可以参考一下的博客,比较详细

refer to:

http://blog.chinaunix.net/space.php?uid=742107&do=blog&id=214330

http://www.linuxsir.org/main/node/152?q=node/152#5

9. 建立过程中出现的问题:大多是windows上传中文编码的问题,网上主要有两种方法:

a. 修改i18n,如果修改为zh_CNgb18030

    这样是解决了乱码,但是也会造成终端下 执行命令的乱码情况,而且这样ibus的首选项就打不开了,也无法切换输入法,个人不建议使用

b. 还有个2.03版的修正吧,尝试了一下,但是没有成功,在main中有错误,附网址(http://zhumeng8337797.blog.163.com/blog/static/10076891420109210304328/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值