目录
1.搭建centos 7
2.Linux环境下部署ftp
1.首先,我们执行安装
2.然后我们进入文件夹查看一下是否有问题
3.我们先给linux系统添加一个登录ftp的账户
4. 我们需要限制FTP登录的人数,我们进入 vsftpd 目录下的 user_list 中修改,
5.完成以上步骤我们接下来要配置 vsftpd.conf 这个核心文件,下面是该文件里的内容:
6.我们还没有创建这个目录,所以先来创建目录
7.目录创建成功后,更改目录访问用户
3.使用filezilla测试ftp文件上传功能
1.使用filezilla连接试试,可能会有如下问题:
2.登录成功了,然后又出现了一个新的问题
3.有些可能会出现这个错误
3.还有些人在用filezilla创建文件目录的时候会报错
550 create directory operation failed
4.还有些会碰到权限问题
530 Permission denied解决方法
5.还有一些在上传文件会碰到的文件
553 Could not create file.
最后就可以成功访问了
1.搭建centos 7
1.打开VMware 点击创建新的虚拟机
2.选择centos7镜像进行导入
3. 填写用户名密码信息
如果出现这个问题,解决方案:改一下用户名就可以
4.编辑虚拟机名称和存放位置
5.选择磁盘大小,直接单击下一步即可
6.可以点击自定义硬件编辑一些虚拟机内存等配置,修改完成后点击完成即可
7.首先,将下载好的iso映像文件选中,点击确定,就可以开启此虚拟机,正式进入centos7安装界面了
注:在开启虚拟机的时候可能会碰到此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态 的问题
已将该虚拟机配置为使用 64 位客户机操作系统。但是,无法执行 64 位操作。
此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态。
如果已在 BIOS/固件设置中禁用 Intel VT-x,或主机自更改此设置后从未重新启动,则 Intel VT-x 可能被禁用。
(1) 确认 BIOS/固件设置中启用了 Intel VT-x 并禁用了“可信执行”。
(2) 如果这两项 BIOS/固件设置有一项已更改,请重新启动主机。
(3) 如果您在安装 VMware Workstation 之后从未重新启动主机,请重新启动。
(4) 将主机的 BIOS/固件更新至最新版本。
一、进入BIOS
重启系统,进入BIOS,我的系统是按F2键进入BIOS的
参考以下按键,开机时按住对应的键进入BIOS:
组装机以主板分,华硕按F8、Intel按F12,其他品牌按ESC、F11或F12;
笔记本以品牌分,联想ThinkPad系列按F1,其他品牌按F2;
品牌台式机按品牌分, Dell按ESC,其他按F12;
如果仍然不能进入BIOS,找找电脑(主板)说明书或者参考BIOS设置怎么进入图解教程。
二、开启VT
1、Phoenix BIOS机型
(1)进入BIOS,选择Configuration选项,选择Intel Virtual Technology并回车。注意:若无VT选项或不可更改,则表示你的电脑不支持VT技术。此时该选项应该是disabled(关闭)的;
(2)将光标移动至Enabled处,并回车确定。
(3) 此时该选项将变为Enabled,最后按F10热键保存并退出即可开启VT功能。
(4) 保存设置,重启即可。
再次进入vmware,就可以正常安装了。
原创:
8.进入之后选择语言偏好
9.然后等待安装即可,也可以创建新的用户
10.最后,输入用户名和密码即可进入桌面
11.进入之后找到控制台
12.输入ifconfig即可查看虚拟机对应的ip地址
13.在MoBaXTerm等软件中连接虚拟机对应服务器地址
2.Linux环境下部署ftp
1.首先,我们执行安装
命令:yum install -y vsftpd
注意:如果出现 Loaded plugins: fastestmirror错误
那就是yum的加速插件 失效了
vim /etc/yum/pluginconf.d/fastestmirror.conf
把enabled=1 改成 enabled=0即可;
当出现complate即为安装成功了
2.然后我们进入文件夹查看一下是否有问题
cd /etc/vsftpd/ 进入FTP文件夹中查看文件,会看有四个文件,如下:
-rw------- 1 root root 125 Mar 22 2017 ftpusers 黑名单文件,此文件里的用户不允许访问 FTP 服务器 -rw------- 1 root root 361 Mar 22 2017 user_list 白名单文件,是允许访问 FTP 服务器的用户列表 -rw------- 1 root root 4599 Mar 22 2017 vsftpd.conf 核心配置文件 -rwxr--r-- 1 root root 338 Mar 22 2017 vsftpd_conf_migrate.sh FTP服务
3.我们先给linux系统添加一个登录ftp的账户
useradd ftpuser # 红色是用户名,可以任意定义
然后设置一下密码
passwd ftpuser
输入两遍密码后创建/修改成功
4. 我们需要限制FTP登录的人数,我们进入 vsftpd 目录下的 user_list 中修改,
vim user_list
如下:
# vsftpd userlist # If userlist_deny=NO, only allow users in this file # If userlist_deny=YES (default), never allow users in this file, and # do not even prompt for a password. # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers # for users that are denied. root ftpuser
将你的用户名输入进去即可
输入完成后退出并且输入:wq进行保存
注:user_list 里面的内容是能够登录FTP的用户列表,若是不想让其他用户登录,则删除该文件内的其他用户名,仅保留我们刚才创建的一个用户(root为系统管理员,若是不需要也可以删除)。
5.完成以上步骤我们接下来要配置 vsftpd.conf 这个核心文件,下面是该文件里的内容:
# 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 # # 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,
以上配置我们需要更改一个地方,在anonymous_enable=YES这里将YES改为NO,禁止匿名用户访问
然后在下面新增local_root=/data/ftp 指定用户访问的主目录(ftp文件存放目录)
修改完成后退出
6.我们还没有创建这个目录,所以先来创建目录
mkdir -p /data/ftp
7.目录创建成功后,更改目录访问用户
命令:chown -R ftpuser /data/ftp
注意:当是从阿里云或者天翼云上部署FTP的时候,当部署完毕之后一定要开放你的端口规则,不然你是无法访问默认端口的(也就是你无法访问FTP服务器,默认端口为21,20)
3.使用filezilla测试ftp文件上传功能
1.打开filezilla输入主机(ip地址)、用户名、密码、端口号(默认21)即可连接
1.使用filezilla连接试试,可能会有如下问题:
这是FTP的主动模式和被动模式造成的,所以我选择了一个很简单的方式来解决:如下
2.登录成功了,然后又出现了一个新的问题
关闭防火墙或者是在防火墙内开放 21 端口即可,如下:
关于关闭防火墙:
systemctl status firewalld.service 查看防火墙状态
然后在下方可以查看得到“active(running)”,此时说明防火墙已经打开了。
在命令行中输入systemctl stop firewalld.service命令,进行关闭防火墙。
注:只是暂时关闭防火墙
然后再使用命令systemctl status firewalld.service,在下方出现disavtive(dead),这样就说明防火墙已经关闭。
在命令行中输入命令“systemctl disable firewalld.service”命令,即可永久关闭防火墙。
3.有些可能会出现这个错误
为了解决暴露在公网的 FTP 传输的安全,我们必须对 vsftpd 进行配置 ssl
1.检查 vsftpd 是否支持 ssl 模块
命令:grep ssl
2.CentOS有一个建立凭证的地方/etc/pki/tls/certs/
# cd /etc/pki/tls/certs
生成密钥文件(后按照证书配置进行配置虚拟证书)
# make vsftpd.pem
# 复制证书到vsftpd目录
# cp -a vsftpd.pem /etc/vsftpd/
# ll /etc/vsftpd/vsftpd.pem
证书配置解析:
Country Name (2 letter code) [XX]:CN 国家名称(2个字母代码)[XX]:CN
State or Province Name (full name) []:CHINA 国家或省名(全称)[]:中国
Locality Name (eg, city) [Default City]:CHINA 地名(如城市)[默认城市]:中国
Organization Name (eg, company) [Default Company Ltd]:ORG 组织名称(如公司)[默认公司有限公司]:ORG
Organizational Unit Name (eg, section) []:ORG 组织单元名称(例如,节)[]:ORG
Common Name (eg, your name or your server's hostname) []:NAME 常用名称(例如,您的名称或服务器的主机名)[]:Name
Email Address []:EMAIL@163 电子邮件地址[]:EMAIL@163
3.停止服务
# service vsftpd stop
4.在最后加上以下配置
ssl_enable=YES
allow_anon_ssl=YES
force_anon_data_ssl=YES
force_anon_logins_ssl=YES
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
rsa_cert_file=/etc/vsftpd/vsftpd.pem
listen_port=8048
配置解析:
###SSL#####
# 是否启用SSL,默认值:NO
ssl_enable=YES
#
# 仅适用于 ssl_enable 活动。如果设置为YES,匿名用户将被允许使用安全的SSL连接
默认值:NO
allow_anon_ssl=YES
#
# 仅适用于 ssl_enable 激活。如果激活,所有匿名登录将被强制使用安全的SSL连接,以便在数据连接上发送和接收数据。默认值:NO
force_anon_data_ssl=YES
#
# 仅适用于 ssl_enable 激活。如果激活,所有匿名登录将被强制使用安全的SSL连接以发送密码。默认值:NO
force_anon_logins_ssl=YES
#
# 仅适用于 ssl_enable 激活。如果激活,所有非匿名登录将被强制使用安全的SSL连接,以便在数据连接上发送和接收数据。默认值:YES
force_local_data_ssl=YES
#
# 仅适用于 ssl_enable 激活。如果激活,所有非匿名登录将被强制使用安全的SSL连接以发送密码。默认值:YES
force_local_logins_ssl=YES
#
# 仅适用于 ssl_enable 激活。如果启用,此选项将允许TLS v1协议连接。TLS v1连接是首选。默认值:YES
ssl_tlsv1=YES
#
# 仅适用于 ssl_enable 激活。如果启用,此选项将允许SSL v2协议连接。TLS v1连接是首选。默认值:NO
#ssl_sslv2=NO
#
# 仅适用于 ssl_enable 激活。如果启用,此选项将允许SSL v3协议连接。TLS v1连接是首选。默认值:NO
#ssl_sslv3=NO
#
# 选项指定用于SSL加密连接的RSA证书的位置。默认值:/usr/share/ssl/certs/vsftpd.pem
rsa_cert_file=/etc/vsftpd/vsftpd.pem
5.最后保存,重启服务即可
#启动服务
service vsftpd start
#重启服务
service vsftpd restart
6.在连接的时候勾选信任证书就行
(原创:https://blog.csdn/weixin_42867972/article/details/88716341)
3.还有些人在用filezilla创建文件目录的时候会报错
550 create directory operation failed
这种情况就关闭你默认的linux配置即可
1.打开文件
命令:vim /etc/selinux/config
2.修改如下配置
SELINUX=disabled
3.然后重启服务器
4.CentOS7下查看vsftpd服务的状态
命令:systemctl status vsftpd.service
设置开机启动
systemctl enable vsftpd.service
4.还有些会碰到权限问题 530 Permission denied解决方法
1.首先检查系统是否开启了vsftp服务,如果没有开启,先开启该服务。
2.查看配置
vsftpd的配置,配置文件中限定了vsftpd用户连接控制配置。
vsftpd.ftpusers:位于/etc/vsftpd目录下。它指定了哪些用户账户不能访问FTP服务器,例如root等。
vsftpd.user_list:位于/etc/vsftpd目录下。该文件里的用户账户在默认情况下也不能访问FTP服务器,仅当vsftpd .conf配置文件里启用userlist_enable=NO选项时才允许访问。
vsftpd.conf:位于/etc/vsftpd目录下。来自定义用户登录控制、用户权限控制、超时设置、服务器功能选项、服务器性能选项、服务器响应消息等FTP服务器的配置。
3.配置修改完成后,执行service vsftpd restart重启vsftpd服务。
5.还有一些在上传文件会碰到的错误 553 Could not create file.
报错信息如下:
响应:&http://www.aliyun/zixun/aggregation/37954.html">nbsp;227 Entering Passive Mode (192,168,1,6,251,12).
命令: LIST
响应: 150 Here comes the directory listing.
响应: 226 Directory send OK.
状态: 列出目录成功
状态: 开始上传 C:\Users\Administrator\AppData\Local\Temp\fz3temp-1\empty_file_yq744zm
命令: PASV
响应: 227 Entering Passive Mode (192,168,1,6,120,119).
命令: STOR fdsaf
响应: 553 Could not create file.
错误: 严重文件传输错误
发现没有权限创建文件或是目录,查找原因,原来是selinux引起的登陆问题。
为避免每次开机都要作这个操作,可在setsebool命令后面加上-P选项,使改动永久有效。
[root@localhost webserver]# sestatus -b| grep ftp
allow_ftpd_anon_write off
allow_ftpd_full_access off
allow_ftpd_use_cifs off
allow_ftpd_use_nfs off
ftp_home_dir on
ftpd_connect_db off
ftpd_use_passive_mode off
httpd_enable_ftp_server off
tftp_anon_write off
如果你使用本地用户登陆vsftpd出现如下错误500 OOPS: cannot change directory:/home/ithov,请参阅这篇文章《vsftpd中FTP登陆500 OOPS: cannot change directory:/home/ithov错误解决方法》
需要设置allow_ftpd_full_access为on状态,
[root@localhost webserver]# setsebool allow_ftpd_full_access on
[root@localhost webserver]# sestatus -b| grep ftp
allow_ftpd_anon_write off
allow_ftpd_full_access on
allow_ftpd_use_cifs off
allow_ftpd_use_nfs off
ftp_home_dir on
ftpd_connect_db off
ftpd_use_passive_mode off
httpd_enable_ftp_server off
tftp_anon_write off
重新登陆ftp再来创建文件或目录,成功啦!
(原创:https://www.aliyun/zixun/content/3_12_518090.html)
最后就可以成功访问了
更多推荐
搭建centos 7 并部署ftp的详细过程
发布评论