在本文中,我们将详细介绍centos搭建vsftp的各个方面,并为您提供关于centos搭建vsftpd的相关解答,同时,我们也将为您带来关于CentOS6.364bit搭建vsFTP服务、CentO
在本文中,我们将详细介绍centos搭建vsftp的各个方面,并为您提供关于centos搭建vsftpd的相关解答,同时,我们也将为您带来关于CentOS 6.3 64bit 搭建 vsFTP 服务、CentOS 6.3 64bit 搭建vsFTP服务、centos 6.3搭建 vsftpd服务器、CentOS 6.5下搭建vsftp服务器的有用知识。
本文目录一览:- centos搭建vsftp(centos搭建vsftpd)
- CentOS 6.3 64bit 搭建 vsFTP 服务
- CentOS 6.3 64bit 搭建vsFTP服务
- centos 6.3搭建 vsftpd服务器
- CentOS 6.5下搭建vsftp服务器
centos搭建vsftp(centos搭建vsftpd)
本文参考链接: 1. https://www.cnblogs.com/surge/p/3868270.html
2. https://www.cnblogs.com/dajianshi/p/3747927.html
2018/11/19
一:安装vsftpd
查看是否已经安装vsftpd
rpm -qa | grep vsftpd
如果没有,就安装,并设置开机启动
yum -y install vsftpd
chkconfig vsftpd on
管理vsftpd相关命令:
启动vsftpd: service vsftpd start
停止vsftpd: service vsftpd stop
重启vsftpd: service vsftpd restart
二、配置防火墙
打开/etc/sysconfig/iptables文件
vi /etc/sysconfig/iptables
在REJECT行之前添加如下代码
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
保存和关闭文件,重启防火墙
service iptables start
三、配置vsftpd服务器
1.默认的配置文件是/etc/vsftpd/vsftpd.conf,你可以用文本编辑器打开。
vi /etc/vsftpd/vsftpd.conf
2.添加ftp用户
下面是添加ftsztx用户,设置根目录为/home/wwwroot/ftpsztxkj,禁止此用户登录SSH的权限,并限制其访问其它目录。
#chroot_list_enable=YES # (default follows) #chroot_list_file=/etc/vsftpd.chroot_list 改为 chroot_list_enable=YES # (default follows) chroot_list_file=/etc/vsftpd/chroot_list
3.增加用户ftpuser,指向目录/home/wwwroot/ftpsztxkj,禁止登录SSH权限。
useradd -d /home/wwwroot/ftpsztxkj -g ftp -s /sbin/nologin ftpsztxkj
4.设置用户口令
passwd ftpsztxkj
5、编辑文件chroot_list:
vi /etc/vsftpd/chroot_list
内容为ftp用户名,每个用户占一行,如:
6、重新启动vsftpd
service vsftpd restart
用linux服务器连接ftp:
用win系统的dos cmd命令打开链接:
出现的错误
1、500 OOPS: cannot change directory
解决方法:
在终端输入命令:
setsebool -P ftpd_disable_trans 1
输入这个命令报错:Boolean ftpd_disable_trans is not defined
使用下面的命令解决。
sestatus –b | grep ftp #查看ftp的各个组件状态
sestatus –P ftp_home-dir 1 #将这个打开,1代表on
service vsftpd restart
就OK了!
原因:这是因为服务器开启了selinux,这限制了FTP的登录。
CentOS 6.3 64bit 搭建 vsFTP 服务
1、废话少说,开始吧。
找到你的centos版本的镜像文件,去到里面这个路径,找到并安装两个rpm
rpm -ivh vsftpd-2.2.2-11.el6.x86_64.rpm //FTP核心文件
rpm -ivh db4-4.7.25-17.el6.x86_64.rpm //虚拟用户必要工具
2、修改配置文件 (下面的 //中文建议都去掉吧,避免问题,这里加上只是解析一下)
mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.confbak //备份
vi /etc/vsftpd/vsftpd.conf //创建配置文件
列出我的配置,根据环境修改做适当修改,注意每行后面不可有空格
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=NO
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
nopriv_user=ftpde
async_abor_enable=YES
ascii_upload_enable=YES
ascii_download_enable=YES
ftpd_banner=Welcome to blah FTP service.
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
#You need to add content
background=YES
guest_enable=YES
guest_username=ftpde
user_config_dir=/etc/vsftpd/user_config
max_clients=100
max_per_ip=20
pasv_enable=YES
listen_port=40001
pasv_min_port=40002
pasv_max_port=40010
3、创建本地用户ftpde 以及chroot虚拟用户映射文件
useradd ftpde //创建ftpde用户,此用户为系统用户
vi /etc/vsftpd/vsftpd.chroot_list
ftpde
//该文件为手动建立,每一行代表一个欲将虚拟用户映射到本地账户的名称
4、创建用户账户文件passwd.file
该文件默认也不存在的,该文件用来存储用户账户以及明文密码,格式为每个账户两行,第一行是用户名,第二行是密码,以此类推!
vi /etc/vsftpd/passwd.file
ftpdemo
123456
5、生成虚拟用户认证的db文件,执行下面命令
db_load -T -t hash -f /etc/vsftpd/passwd.file /etc/vsftpd/ftpuser_passwd.db
6、创建用户配置文件(ftpdemo只是一个样例账号,自己可以另外取名,然后各个地方对应好,即可)
建立好账户后,需要为每个用户创建记录FTP目录位置、用户权限等信息的配置文件
mkdir /etc/vsftpd/user_config
配置文件以FTP用户名为文件名称,每个FTP用户一个文件,例如ftedemo
vi /etc/vsftpd/user_config/ftpdemo
内容如下(//中文的内容, 建议去掉):
local_root=/data/FTP/ftpdemo //该路径对应的目录必须存在,下一步创建
write_enable=YES
anon_umask=022
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
7、创建ftp用户目录,并赋读/写权限
mkdir -p /data/FTP/ftpdemo
FTP
用户所映射到的系统帐户必须对 FTP
用户主目录拥有相应的读/写权限。仍然以ftpdemo用户为例,本文中ftpdemo虚拟用户是被映射到ftpde系统帐户的,所以 ftpde
系统帐户必须拥有对ftpdemo 的 FTP 主目录/data/FTP/ftpuser 的读/写权限
chown -R ftpde:ftpde /data/FTP/ftpdemo/
8、修改Pam 认证模块
备份原有配置文件
mv /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak
创建新配置文件
vi /etc/pam.d/vsftpd具体内容如下:
auth required pam_userdb.so db=/etc/vsftpd/ftpuser_passwd
account required pam_userdb.so db=/etc/vsftpd/ftpuser_passwd
9、修改防火墙
vi /etc/sysconfig/iptables
配置如下:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 40001:40010 -j ACCEPT
重起防火墙,使配置生郊
service iptables restart
10、关闭selinux
setenforce 0 //临时关闭,重起系统失效
或者修改selinux配置关闭selinux
vi /etc/selinux/config
SELINUX=disable
或者其他的各种方法:
如果出现:“500 OOPS: cannot change directory:/home/xxx”
参考解决:
11、重启vsftp
service vsftpd restart
12、使用FTP等工具试试吧。个人使用filezilla很不错。
CentOS 6.3 64bit 搭建vsFTP服务
1、废话少说,开始吧。
找到你的centos版本的镜像文件,去到里面这个路径,找到并安装两个rpm
rpm -ivh vsftpd-2.2.2-11.el6.x86_64.rpm //FTP核心文件
rpm -ivh db4-4.7.25-17.el6.x86_64.rpm //虚拟用户必要工具
2、修改配置文件 (下面的 //中文建议都去掉吧,避免问题,这里加上只是解析一下)
mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.confbak //备份
vi /etc/vsftpd/vsftpd.conf //创建配置文件
列出我的配置,根据环境修改做适当修改,注意每行后面不可有空格
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=NO
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
nopriv_user=ftpde
async_abor_enable=YES
ascii_upload_enable=YES
ascii_download_enable=YES
ftpd_banner=Welcome to blah FTP service.
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
#You need to add content
background=YES
guest_enable=YES
guest_username=ftpde
user_config_dir=/etc/vsftpd/user_config
max_clients=100
max_per_ip=20
pasv_enable=YES
listen_port=40001
pasv_min_port=40002
pasv_max_port=40010
3、创建本地用户ftpde 以及chroot虚拟用户映射文件
useradd ftpde //创建ftpde用户,此用户为系统用户
vi /etc/vsftpd/vsftpd.chroot_list
ftpde
//该文件为手动建立,每一行代表一个欲将虚拟用户映射到本地账户的名称
4、创建用户账户文件passwd.file
该文件默认也不存在的,该文件用来存储用户账户以及明文密码,格式为每个账户两行,第一行是用户名,第二行是密码,以此类推!
vi /etc/vsftpd/passwd.file
ftpdemo
123456
5、生成虚拟用户认证的db文件,执行下面命令
db_load -T -t hash -f /etc/vsftpd/passwd.file /etc/vsftpd/ftpuser_passwd.db
6、创建用户配置文件(ftpdemo只是一个样例账号,自己可以另外取名,然后各个地方对应好,即可)
建立好账户后,需要为每个用户创建记录FTP目录位置、用户权限等信息的配置文件
mkdir /etc/vsftpd/user_config
配置文件以FTP用户名为文件名称,每个FTP用户一个文件,例如ftedemo
vi /etc/vsftpd/user_config/ftpdemo
内容如下(//中文的内容, 建议去掉):
local_root=/data/FTP/ftpdemo //该路径对应的目录必须存在,下一步创建
write_enable=YES
anon_umask=022
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
7、创建ftp用户目录,并赋读/写权限
mkdir -p /data/FTP/ftpdemo
FTP
用户所映射到的系统帐户必须对 FTP
用户主目录拥有相应的读/写权限。仍然以ftpdemo用户为例,本文中ftpdemo虚拟用户是被映射到ftpde系统帐户的,所以 ftpde
系统帐户必须拥有对ftpdemo 的 FTP 主目录/data/FTP/ftpuser 的读/写权限
chown -R ftpde:ftpde /data/FTP/ftpdemo/
8、修改Pam 认证模块
备份原有配置文件
mv /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak
创建新配置文件
vi /etc/pam.d/vsftpd具体内容如下:
auth required pam_userdb.so db=/etc/vsftpd/ftpuser_passwd
account required pam_userdb.so db=/etc/vsftpd/ftpuser_passwd
9、修改防火墙
vi /etc/sysconfig/iptables
配置如下:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 40001:40010 -j ACCEPT
重起防火墙,使配置生郊
service iptables restart
10、关闭selinux
setenforce 0 //临时关闭,重起系统失效
或者修改selinux配置关闭selinux
vi /etc/selinux/config
SELINUX=disable
或者其他的各种方法:
如果出现:“500 OOPS: cannot change directory:/home/xxx”
参考解决:
11、重启vsftp
service vsftpd restart
12、使用FTP等工具试试吧。个人使用filezilla很不错。
centos 6.3搭建 vsftpd服务器
1.首先需要安装vsftpd
yum -y install vsftpd
2.安装后开启vsftpd
service vsftpd start
如果每次开机启动 需要运行如下命令
chkconfig --level 35 vsftpd on
3.设置ftp权限
vi /etc/vsftpd/vsftpd.conf
将anonymous_enable=YES 改成 anonymous_enable=NO
保存退出
4.添加ftp账号和目录
user add -d /home/test.com -s /sbin/nologin test
passwd test
输入test的密码
chmod -R 755 /home/test.com
chown -R testt /home/test.com
重启vsftpd
service vsftpd restart
用ftp连接时可能会报500 cannot change /home/test.com 下面是解决方法
先查看seLinux 的状态
sestatus -b | grep ftp
看到ftp_home_dir off 或 tftpd_disable_trans off 之类的。只需要把其中一个设为on 就可以了
setsebool -P ftp_home_dir on
重启vsftpd
service vsftpd restart
登录成功
5.让登录的用户访问自己的目录
vi vsftpd.conf
chroot_local_user = YES
去除这个的#保存重启vsftpd即可
centos8 出现 530 Login incorrect.
tail -f /var/log/secure查看错误信息,根据相应信息修改
如果没有信息,则修改/etc/pam.d/vsftpd文件,注释掉auth required pam_shells.so,重启v是否图片的即可
使用Filezilla时提示------服务器发回了不可路由的地址,使用服务器地址代替
解决方法:
更改Filezilla设置,编辑 - 设置 - 连接-FTP-被动模式,将“使用服务器的外部IP地址来代替”改为“回到主动模式”即可。
CentOS 6.5下搭建vsftp服务器
#
# 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
#
# 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
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
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
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file,YES to xferlog_file
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 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=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
#
# 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
关于centos搭建vsftp和centos搭建vsftpd的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于CentOS 6.3 64bit 搭建 vsFTP 服务、CentOS 6.3 64bit 搭建vsFTP服务、centos 6.3搭建 vsftpd服务器、CentOS 6.5下搭建vsftp服务器等相关知识的信息别忘了在本站进行查找喔。
本文标签: