搭建简单FTP服务器以及过程中容易遇到的几个问题(一)

FTP 是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”。用于Internet上的控制文件的双向传输。同时,它也是一个应用程序(Application)。

FTP的服务器软件有很多下面就拿vsftpd举例。

vsftpd 是一款在Linux发行版本里面最主流的FTP服务器程序,特点是小巧轻快,安全易用

下面开始安装

先检测是否存在vsftp服务

[[email protected] ~]# rpm -qa |grep vsftpd

没有,下面开始安装

[[email protected] ~]# yum install vsftpd* -y

使用vsftpd软件,主要包括如下几个命令:

启动ftp命令  #service vsftpd start

停止ftp命令  #service vsftpd stop

重启ftp命令  #service vsftpd restart

[[email protected] ~]# /etc/init.d/vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

访问:失败

错误排查:防火墙没关闭

[[email protected] ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[[email protected] ~]#

连上(但是是秘名用户就能访问)

下面我们开始更改一下配置文件

[[email protected] ~]# vi /etc/vsftpd/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=NO      //禁止匿名用户访问
#
# Uncomment this to allow local users to log in.
local_enable=YES    //允许本地用户登录FTP
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES    //运行用户在FTP目录中有写入的权限
#
# 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    //设置本地用户的文件生成掩码为022,默认为077
#
# 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    //启用FTP数据端口的连接请求
#
# 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    //让vsftpd处于独立启动监听端口模式#
# 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    //设置PAM认证服务配置文件名称,文件存放在/etc/pam.d/目录
userlist_enable=YES    //用户列表中的用户是否允许登录FTP服务器
tcp_wrappers=YES    //使用tcp_wrappwers作为主机访问控制方式

下面我设置成禁止用户访问模式

然后定义一个用户名

[[email protected] ~]# useradd test
[[email protected] ~]# passwd test
Changing password for user test.
New password:
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[[email protected] ~]# 

密码设置为123

然后访问一下:

但是访问不进去:

百度了一下才知道是 selinux的问题

[[email protected] ~]# vi /etc/selinux/config

重启一下

[[email protected] ~]# reboot 

Broadcast message from [email protected]
    (/dev/pts/0) at 18:42 ...

The system is going down for reboot NOW!
[[email protected] ~]# 

查看是否关闭了

[[email protected] ~]# sestatus
SELinux status:                 disabled
[[email protected] ~]#

最简单的FTP服务器就搭建好了

下次将介绍一个稍微复杂的FTP服务器

时间: 2024-10-18 11:43:50

搭建简单FTP服务器以及过程中容易遇到的几个问题(一)的相关文章

Linux中搭建一个ftp服务器详解

来源:Linux社区  作者:luzhi1024 详解Linux中搭建一个ftp服务器. ftp工作是会启动两个通道:控制通道 , 数据通道在ftp协议中,控制连接均是由客户端发起的,而数据连接有两种模式:port模式(主动模式)和pasv(被动模式)PORT模式:在客户端需要接收数据时,ftp_client(大于1024的随机端口)-PORT命令->ftp_server(21)  发送PORT命令,这个PORT命令包含了客户端是用什么端口来接收数据(大于1024的随机端口),在传送数据时,ft

在Linux中搭建一个FTP服务器

在Linux中搭建一个ftp服务器,以供两个工作小组保管文件使用.禁用匿名.第一个小组使用ftp账号:ftp1,工作目录在:/var/ftp/ftp1:第二个小组使用ftp2,工作目录在:/var/ftp/ftp2. 两个小组互相不能访问各自的文件,需要限制用户不能离开自己的工作目录. [实现步骤] 1.检查安装vsftpd服务器 以root进入终端后(其他账户进入终端的可以用su root 输入密码后进入root 模式)之后,在终端命令窗口输入以下命令进行验证:# rpm –qa | grep

linux的FTP服务器搭建及FTP服务器的入侵和防御

FTP 是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为"文传协议".用于Internet上的控制文件的双向传输. 与大多数Internet服务一样,FTP也是一个客户机/服务器系统.用户通过一个支持FTP协议的客户机程序,连接到在远程主机上的FTP服务器程序.用户通过客户机程序向服务器程序发出命令,服务器程序执行用户所发出的命令,并将执行的结果返回到客户机. 用户分类 Real帐户 这类用户是指在FTP服务上拥有帐号.当这类用户登录FTP服务器的

一把鼻涕一把泪 搭建公网ftp服务器

至于为什么要搭建公网ftp服务器,就当我心血来潮吧. ftp开源工具很多,咱用的是filezilla服务器.后来为了方便搭建web服务器,就改成了集成工具xampp.客户端工具也是filezilla client,用浏览器也行. 首先内网用户想搭建公网ftp服务器第一个要解决的问题是如何得到公网ip.经过认真试验仔细研究得到两种方案: 1.设置路由器参数,增加转发规则,外网21端口转发到内网21端口: 2.还是设置路由器,设置dmz主机,把自己的内网ip地址填上去,路由器的公网ip就成了自己电脑

[转]windows 7系统搭建本地SVN服务器的过程

windows 7系统搭建本地SVN服务器的过程 1.安装svn:TortoiseSVN-1.7.9.23248-x64-svn-1.7.6; 1.在PC机的D盘创建如下目录:D:\svn\project\workspace; 2.右键点击目录workspace文件,选择Tortoise->Create repository here,即在此创建版本库(Y); 然后你就会看到D:\svn\project\workspace 里面多了conf, db, hooks, lock等文件,版本库创建成功

搭建简单FTP

搭建简单FTP 环境 CentOS 7 安装 yum install vsftpd 修改配置文件, 在/etc/vsftpd/vsftpd.conf中添加allow_writeable_chroot=YES, local_root=/home/ftpuser/share, chroot_local_user=YES 创建ftpuser, useradd ftpuser, echo yourpass | passwd --stdin ftpuser 启动 systemctl start vsftp

搭建简单DHCP服务器

实验01:搭建简单DHCP服务器 实验目标 搭建简单DHCP服务器 实验步骤 环境准备 安装一台RHEL6.5虚拟机 1)内存1G.硬盘80G.软件包(桌面.开发工具) 2)关闭防火墙.关闭SELinux机制 提示:修改 /etc/selinux/config,设置SELINUX=permissive getenforce.setenforce 3)安装好vmware-tools 4)网络配置:VMnet4, svr5.tarena.com  192.168.4.5/24 提示:关闭 Netwo

4步win7下简单FTP服务器搭建(试验成功)

本文介绍通过win7自带的IIS来搭建一个只能实现基本功能的FTP服务器,第一次装好WIN7后我愣是没整出来,后来查了一下网上资料经过试验后搭建成功,其实原理和步骤与windows前期的版本差不多,主要是对新的操作系统还不是很熟悉.相信用过WIN7一段时间的都能独立解决掉.      主要分为4个步骤     1.安装FTP服务     2.在IIS控制面板里添加FTP站点     3.配置FTP站点 4. 测试站点是否正常工作   ftp://192.168.10.13

win7下简单FTP服务器搭建

本文介绍通过win7自带的IIS来搭建一个只能实现基本功能的FTP服务器,第一次装好WIN7后我愣是没整出来,后来查了一下网上资料经过试验后搭建成功,其实原理和步骤与windows前期的版本差不多,主要是对新的操作系统还不是很熟悉.相信用过WIN7一段时间的都能独立解决掉.     主要分为4个步骤    1.安装FTP服务 2.在IIS控制面板里添加FTP站点 转自http://blog.sina.com.cn/s/blog_3f7e47f20100haur.html 3.配置FTP站点 4.