安装vsftpd服务

$ sudo apt install vsftpd

配置参数

命令输入

$ vim /etc/vsftpd.conf

使用如下配置

# Example config file /etc/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. for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf. manual page to get a full idea of vsftpd's
# capabilities.
#
#
# Run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=NO
#
# 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.
listen_ipv6=YES
#
# Allow anonymous FTP? (Disabled by default).
anonymous_enable=NO
#
# 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 \. You may wish to change this to ,
# if your users expect that ( is used by most other ftpd's)
local_umask=
#
# 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
#
# If enabled, vsftpd will display directory listings with the time
# in your local time zone. The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port (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=
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=
#
# 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 restrict local users to their home directories. See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# 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
user_sub_token=$USER
local_root=/home/$USER/
ftp
# (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
#
# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=ftp
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=
NO #
# Uncomment this to indicate that vsftpd use a utf8 filesystem.
utf8_filesystem=YES

配置说明

  • anonymous_enable=NO 拒绝匿名登陆

  • write_enable=YES 设置可以上传文件,这个设置看需要个人需要

  • xferlog_enable=YES 开启日志记录

  • xferlog_file=/var/log/vsftpd.log 设置日志文件路径

  • xferlog_std_format=YES 设置日志格式为标准输出

  • connect_from_port_20=YES 绑定20端口

  • ftpd_banner=Welcome to FTP service. 欢迎语句,在使用shell时可以看到

  • chroot_local_user=YES

  • chroot_list_enable=YES

  • chroot_list_file=/etc/vsftpd.chroot_list
    上面的这几个配置实现的功能是:用户被限制在自己的主目录下。用户名单来源于/etc/vsftpd.chroot_list

  • user_sub_token=$USER

  • local_root=/home/$USER/ftp
    添加一个user_sub_token ,以便插入用户名在我们local_root directory路径,以便我们的配置将为该用户,并可能被添加任何未来的用户

  • pam_service_name=ftp原配置中为vsftpd,ubuntu和Debian用户需要更改成ftp(折腾良久,一直提示拒绝登陆,问题的关键点在这里!)

如果登录后出现如下错误,则在/etc/vsftpd.conf文件内添加allow_writeable_chroot=YES

 
 OOPS: vsftpd: refusing to run with writable root inside chroot ()

创建ftp用户

$ mkdir /home/ftpuser
$ sudo useradd ftpuser -g ftpgroup -d /home/ftpuser -m
$ sudo passwd ftpuser
$ mkdir /home/ftpuser/ftp
$ chmod -R /home/username/ftp
$ usermod -s /sbin/nologin ftpuser

/etc/vsftpd.chroot_list要自己创建,并将ftpuser放进去

启动vsftpd或者重启

  • systemctl start vsftpd 或 service vsftpd start
  • systemctl restart vsftpd 或 service vsftpd restart

登陆

使用filezilla或者打开文件管理器输入ftp://ipaddress

本片博文转自简书:https://www.jianshu.com/p/379d774a48d3

 
在此说明,简书是个很好的互联网分享平台,但是为什么我不在上面写文章而选择博客园。直接原因是确实被饱醉豚事件恶心到了。其次简述综合性太强,涉及面太杂。不太适合作为一个技术交流平台。

Debian系统下的ftp服务搭建的更多相关文章

  1. debian系统下安装ssh服务

    它是什么?? SSH 为 Secure Shell 的缩写,简单地说,SSH 为建立在应用层基础上的安全协议.SSH 是目前较可靠,专为远程登录会话和其他网络服务提供安全性的协议.利用 SSH 协议可 ...

  2. CentOS7 FTP服务搭建(虚拟用户访问FTP服务)

    概述 最近在搞Oracle在Linux系统下集群,针对Linux系统,笔人也是一片空白.Liunx外部文件的传输,避免不了使用FTP服务,所以现在就整理下,CentOS7环境下,FTP服务的搭建.FT ...

  3. linux之FTP服务搭建 ( ftp文件传输协议 VSFTPd虚拟用户)

    FTP服务搭建 配置实验之前关闭防火墙 iptables -F iptables -X iptables -Z systemctl stop firewalld setenforce 0 1.ftp简 ...

  4. 在Windows XP系统下架设FTP服务器需要5个步骤。

    4步win7下简单FTP服务器搭建:http://blog.sina.com.cn/s/blog_3f7e47f20100haur.html 申请网域护照(即帐户),开通免费域名.连接到www.ora ...

  5. Windows 下开启FTP服务并创建FTP用户

    Windows 下开启FTP服务,并创建用户 此教程教你怎么开启 Windows 的 FTP 服务,并创建用于登入 FTP 的用户.教程用到的操作系统是 Windows 7. 一.创建用于登入 FTP ...

  6. CentOS7.0下安装FTP服务的方法

    http://www.jb51.net/article/106604.htm   本篇文章主要介绍了CentOS7.0下安装FTP服务的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟 ...

  7. mac下打开FTP服务

    MAC下打开FTP服务 周银辉 mac下一般用smb服务来进行远程文件访问,但要用FTP的话,高版本的mac os默认关掉了,可以用如下命令打开: sudo -s launchctl load -w ...

  8. Debian系统下实现通过wpa_config连接WPA-PSK加密的Wifi连接

    Debian系统下实现通过wpa_config连接WPA-PSK加密的Wifi连接 文章参考:BASST | BLOG : Setting up Wifi - Debian Wheezy 预环境 De ...

  9. 如何在linux下开启FTP服务

    如何在linux下开启FTP服务 1. 首先服务器要安装ftp软件,查看是否已经安装ftp软件下:   #which vsftpd   如果看到有vsftpd的目录说明服务器已经安装了ftp软件 2. ...

随机推荐

  1. Webpack探索【12】--- externals详解

    本文主要讲externals相关内容. https://segmentfault.com/a/1190000012113011

  2. join中级篇---------hash join & merge join & nested loop Join

    嵌套循环连接(Nested Loop Join) 循环嵌套连接是最基本的连接,正如其名所示那样,需要进行循环嵌套,嵌套循环是三种方式中唯一支持不等式连接的方式,这种连接方式的过程可以简单的用下图展示: ...

  3. [2018-11-27]2018年12月1日宁波dotnet社区线下活动

    离上次活动,转眼又过了一个月,幸得各路大神支持,于本周六(12月1日),宁波dotnet社区的线下分享活动又来啦! 活动嘉宾及主题 董斌辉 2015-2019年微软全球最有价值专家(.NET方向) 2 ...

  4. JAVA使用相对路径读取配置文件

    JAVA使用相对路径读取配置文件[align=center][/align][size=medium][/size]   在软件开发中经常遇到读取配置文件,以及文件定位问题.今天做个总结.   (一) ...

  5. SQLSERVER2008 R2的端口设置

    通过存储过程查看 我们首先打开sqlserver连接sqlserver2008的数据库实例,然后执行如下存储过程: --查询端口号 exec sys.sp_readerrorlog 0, 1, 'li ...

  6. loj#2269. 「SDOI2017」切树游戏

    还是loj的机子快啊... 普通的DP不难想到,设F[i][zt]为带上根玩出zt的方案数,G[i][zt]为子树中的方案数,后面是可以用FWT优化的 主要是复习了下动态DP #include< ...

  7. jsp和servlet的区别联系

    jsp和servlet的区别联系 简单的说,SUN首先发展出SERVLET,其功能比较强劲,体系设计也很先进,只是,它输出HTML语句还是采用了老的CGI方式,是一句一句输出,所以,编写和修改HTML ...

  8. centos7搭建redis主从复制,并模拟故障切换。

    Cntos7搭建redis主从复制,并模拟故障主从切换 主从复制搭建 主机:192.168.161.179 从机:192.168.161.180 1.        安装主redis 自己本地环境,关 ...

  9. haproxy透传用户ip-方法和原理

    为了透传用户ip到后端server, proxy机器需要解决两个问题: 1.在创建到后端server的套接字时, 将用户ip作为套接字的源ip,从而让后端server看到: 2.后端server在回包 ...

  10. skynet实践(9)-随机数重复问题

    最近在使用skynet的过程中,遇到需要为玩家的每次请求产生一个随机序列的场景.简化如下: main.lua中每隔1S便发出一次随机数请求: local skynet = require " ...