linux上搭建ftp服务器
摘要
vsftpd
是“very secure FTP daemon”的缩写,安全性是它的一个最大的特点。vsftpd 是一个 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux、BSD、Solaris、 HP-UNIX等系统上面,是一个完全免费的、开放源代码的ftp服务器软件,支持很多其他的 FTP 服务器所不支持的特征。比如:非常高的安全性需求、带宽限制、良好的可伸缩性、可创建虚拟用户、支持IPv6、速率高等。
vsftpd
是一款在Linux
发行版中最受推崇的FTP
服务器程序。特点是小巧轻快,安全易用。(来自百度百科)
安装vsftpd
检测是否已经安装vsftpd。
[root@localhost ~]# rpm -qa | grep vsftpd
[root@localhost ~]#
什么都不显示就没有安装
安装vsftpd
使用yum安装
[root@localhost ~]# yum -y install vsftpd
使用rpm安装
[root@localhost local]# rpm -ivh vsftpd-3.0.2-21.el7.x86_64.rpm
启动服务
[root@localhost local]# service vsftpd start
Redirecting to /bin/systemctl start vsftpd.service
查看服务状态
[root@localhost local]# service vsftpd status
Redirecting to /bin/systemctl status vsftpd.service
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
Active: active (running) since 三 2017-08-30 15:28:18 CST; 15min ago
Process: 4295 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 4296 (vsftpd)
CGroup: /system.slice/vsftpd.service
└─4296 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
8月 30 15:28:18 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...
8月 30 15:28:18 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.
Hint: Some lines were ellipsized, use -l to show in full.
Active: active (running) 启动状态,可以使用
现在我们就可以匿名访问了
vsftpd添加用户
vsftpd添加用户
FTP用户一般是不能登录系统的,只能进入FTP服务器自己的目录中,这是为了安全.这样的用户就叫做虚拟用户了.实际上并不是真正的虚拟用户,只是不能登录SHELL了而已,没能力登录系统.
添加用户命令
/usr/sbin/adduser -d /opt/test_ftp -g ftp -s /sbin/nologin test2
上面的命令是添加一个 名称为 test2的用户。
命令解析:使用命令(adduser)添加test2用户,不能登录系统(-s /sbin/nologin),自己的文件夹在(-d /opt/test_ftp)),属于组ftp(-g ftp).
为该用户设置密码
[root@localhost local]# passwd test2
现在重启服务我们就可以使用test2直接访问我们的 /opttest_ftp目录了
给用户权限上传下载,修改
虽然用户能够进行查看,但是还没有权限上传、下载和修改
授权
[root@localhost local]# chmod 755 /opt/test_ftp
编辑配置文件
一般创建一个ftp 用户,作为管理员只希望它只能访问其自己的所属目录的,是不会让他选择其他目录的。
设置ftp用户的权限
在安装好ftp时,在 /etc/vsftpd目录下可以看到vsftpd的配置文件vsftpd.conf
[root@localhost vsftpd]# vim 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.
# When SELinux is enforcing check for SE bool ftp_home_dir
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.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
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/xferlog
#
# 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=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().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
# vsftpd:500 OOPS: vsftpd: refusing to run with writable root inside chroot ()错误的解决方法
allow_writeable_chroot=YES
#
# 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. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then 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
anon_other_write_enable=YES
#anon_root=/opt/test_ftp
#guest_enable=YES
#guest_username=test2
virtual_use_local_privs=YES
用户访问权限及路径限制:
如果 userlist_deny=NO:只允许userlist_file
文件中的用户可访问ftp;如果 userlist_deny=YES
:userlist_file
文件中列举的用户不能通过ftp访问系统。userlist_enable
是该功能的开关。我们的系统配置如下:
userlist_enable=YES
userlist_deny=NO
userlist_file=/etc/vsftpd/user_list
把需要登录的用户加入到/etc/vsftpd/user_list
文件中,一个用户一行。
如果我们不需要把登陆的用户限制在主目录下需要一下配置:
进入主配置文件中chroot_list_enable=YES
创建用户文件/etc/vsftpd/chroot_list
vim /etc/vsftpd/chroot_list
将不需要限制的用户添加进去,我们只有一个test2,一行一个用户名
ps: 这些用户将能访问全部有权限的文件。
设置权限
[root@localhost vsftpd]# getsebool -a|grep ftp
ftpd_anon_write --> off
ftpd_connect_all_unreserved --> off
pd_connect_db --> off
▽tpd_full_access --> off
ftpd_use_cifs --> off
ftpd_use_fusefs --> off
ftpd_use_nfs --> off
ftpd_use_passive_mode --> off
httpd_can_connect_ftp --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_home_dir --> off
开启 anon_write 和full_access
[root@localhost vsftpd]# setsebool allow_ftpd_anon_write 1
[root@localhost vsftpd]# setsebool allow_ftpd_full_access 1
重启ftp服务
[root@localhost vsftpd]# service vsftpd restart
测试
注:测试连接软件是FileZilla
,windows访问 ftp://[ip]
update 20170901 使用FileZilla创建中文文件夹Linux乱码
首先出现这个问题的原因是WINDOWS采用的是GBK
编码方式,而Linux采用的是UTF-8
首先设置好FileZilla的编码方式为zh_CN
在将 /etc/locale.conf
中的LANG
修改为"zh_CN.UTF-8"
[root@localhost ~]# vim /etc/locale.conf
LANG="zh_CN.UTF-8"
这个修改可以有效解决windows客户端使用ftp协议上传中文文件到Linux乱码的问题。
其实最根本的解决方法是客户端上传的文件经过ftp软件能与服务器统一编码方式,具体百度吧c#、java的都有。
博客地址
linux上搭建ftp服务器的更多相关文章
- CentOS Linux上搭建PPPoE服务器及拨号设置
CentOS Linux上搭建PPPoE服务器及拨号设置 搭建PPPoE,成功了的话,就觉得超级简单,在CentOS Linux更是5步左右就能搞定. 1.安装pppoe,安装完成后,会有pppoe- ...
- linux上构建ftp服务器
linux上构建ftp服务器 服务器搭建 https://help.aliyun.com/knowledge_detail/60152.html,可以参考这篇博文. 配置文件详解 进入/etc/vsf ...
- 【转】Linux环境搭建FTP服务器与Python实现FTP客户端的交互介绍
Linux环境搭建FTP服务器与Python实现FTP客户端的交互介绍 FTP 是File Transfer Protocol(文件传输协议)的英文简称,它基于传输层协议TCP建立,用于Interne ...
- linux上搭建ftp
linux上搭建ftp 重要 解决如何搭建ftp 解决用户指定访问其根目录 解决访问ftp超时连接 解决ftp主动连接.被动连接的问题 1.安装ftp ...
- linux上搭建ftp、vsftp, 解决访问ftp超时连接, 解决用户指定访问其根目录,解决ftp主动连接、被动连接的问题
linux上搭建ftp 重要 解决如何搭建ftp 解决用户指定访问其根目录 解决访问ftp超时连接 解决ftp主动连接.被动连接的问题 1.安装ftp ...
- Linux上的ftp服务器vsftpd之配置满天飞--设置匿名用户访问(不弹出用户名密码框)以及其他用户可正常上传
一.问题背景 没事谁折腾这鬼玩意哦...还不是因为bug. 我们的应用,用户头像是存在ftp上的.之前的ftp服务器是一台windows,我们后台服务器程序收到用户上传头像的请求时,会用一个ROOT/ ...
- 【转】【FTP】之windows8.1上搭建FTP服务器方法
参考地址:<windows8.1上搭建FTP服务器方法>
- linux系统搭建ftp服务器及创建用户使用
linux 系统下搭建ftp服务器 ftp是什么 FTP是 File Transfer Protocol 文件传输协议的英文名称,用于在Internet上控制文件的双向传输. 同时它也是一个应用程序. ...
- 如何在windows上搭建ftp服务器
FTP(File Transfer Protocol)是TCP/IP网络上两台计算机传送文件的协议,使得主机间可以共享文件.目前有很多软件都能实现这一功能,然而windows自带的IIS就可以帮助你搭 ...
随机推荐
- 1、MyEclipse插件配置以及通过MyEclipse生成表对应的JPA代码
去除MyEclipse插件的方式是打开:WindowàCustomize Perspective窗口进行插件配置: 取出下图中不常用的插件勾,最终点击OK. 3.点击OK之后显示的效果图如下: ...
- 如何在Cocos2D 1.0 中掩饰一个精灵(四)
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 为了完成需要的效果,我们将使用如下策略: 我们将首先绘制掩饰精灵 ...
- Java中类的创建及类与对象的关系
//import java.util.Scanner; //创建一个类 class Person{ //属性和方法的定义不是必须的 //属性 String name ; int age ; //方法 ...
- Activity, Service,Task, Process and Thread之间的关系
Activity, Service,Task, Process and Thread之间到底是什么关系呢? 首先我们来看下Task的定义,Google是这样定义Task的:a task is what ...
- volatile实现可见性但不保证原子性
volatile实现可见性但不保证原子性 volatile关键字: 能够保证volatile变量的可见性 不能保证volatile变量复合操作的原子性 volatile如何实现内存可见性: 深入来说: ...
- 《java入门第一季》之tcp协议下的网络编程c/s实现通信交互
需求:客户端向服务器发送数据,服务器端收到数据后向客户端返回数据: 还是使用两台电脑,一台客户端,一台服务器. 客户端代码: import java.io.IOException; import ja ...
- Cocos2D中使用CCDrawNode绘制几何图形崩溃的解决
在cocos2D v3.x中已经不能像在v2.x中那样直接调用ccDrawXXX函数来绘制几何图形了. 我们可以使用CCDrawNode或者CCRenderer来绘制图形. 但是官方的Api手册中说的 ...
- 在多台PC上进行ROS通讯-学习笔记
首先,致谢易科(ExBot)和ROSWiki中文社区. 重要参考文献: Running ROS across multiple machines http://wiki.ros.org/ROS/Tut ...
- J2EE进阶(一)随堂笔记
进公司搞研发,基本上用的都是J2EE框架.若想在公司混个不错的地位,首先技术上必须过关.由于需求所致,自己学习了J2EE一段时间,主要是Struts2,MyBatis(Hibernate的前身),远远 ...
- utl_file包的使用
首先看一下oracle 脚本 /* # $Header: HTMomse12.sql 12.0.4 20121015 Support $ #+============================= ...