首页 > 系统相关 >ubuntu 使用vsftpd 创建FTP服务(用户名密码登录,限制列出目录)

ubuntu 使用vsftpd 创建FTP服务(用户名密码登录,限制列出目录)

时间:2023-07-28 10:35:21浏览次数:36  
标签:FTP chroot vsftpd sudo list etc ubuntu YES



  • vsftpd介绍
  • ubuntu 安装 vsftpd
  • 配置vsftpd
  • 备份vsftpdconfig
  • 编辑vsftpdconfig
  • 创建登录用户
  • 添加vsftpd 登录用户
  • 添加vsftpd登录用户对目录树的权限
  • 重启 vsftpd 服务
  • 验证ftp服务


vsftpd介绍

vsftpd 是“very secure FTP daemon”的缩写,安全性是它的一个最大的特点。vsftpd 是一个 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux、BSD、Solaris、 HP-UNIX等系统上面,是一个完全免费的、开放源代码的ftp服务器软件,支持很多其他的 FTP 服务器所不支持的特征。比如:非常高的安全性需求、带宽限制、良好的可伸缩性、可创建虚拟用户、支持IPv6、速率高等。
vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序。特点是小巧轻快,安全易用。

摘自百度百科-vsftpd

ubuntu 安装 vsftpd

$ sudo apt-get install vsftpd

使用apt安装即可。

配置vsftpd

备份vsftpd.config

$ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig

编辑vsftpd.config

手动修改配置,根据下方的patch文件改一下。

$ sudo vim /etc/vsftpd.config

但是既然做了程序员就要懒一点,能自动就自动好了将配置好的文件与原始文件使用diff 生成的patch 文件,保存到本地,用patch命令更新即可。

--- /etc/vsftpd.conf.orig   2018-02-08 13:39:05.983282023 +0800
+++ /etc/vsftpd.conf    2018-02-10 11:14:15.584088172 +0800
@@ -28,11 +28,11 @@
 local_enable=YES
 #
 # Uncomment this to enable any form of FTP write command.
-#write_enable=YES
+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
+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
@@ -67,11 +67,11 @@
 #
 # You may override where the log file goes if you like. The default is shown
 # below.
-#xferlog_file=/var/log/vsftpd.log
+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
+xferlog_std_format=YES
 #
 # You may change the default value for timing out an idle session.
 #idle_session_timeout=600
@@ -100,7 +100,7 @@
 #ascii_download_enable=YES
 #
 # You may fully customise the login banner string:
-#ftpd_banner=Welcome to blah FTP service.
+ftpd_banner=Welcome Lincoln Linux FTP Service.
 #
 # You may specify a file of disallowed anonymous e-mail addresses. Apparently
 # useful for combatting certain DoS attacks.
@@ -120,9 +120,9 @@
 # the user does not have write access to the top level directory within the
 # chroot)
 #chroot_local_user=YES
-#chroot_list_enable=YES
+chroot_list_enable=YES
 # (default follows)
-#chroot_list_file=/etc/vsftpd.chroot_list
+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
@@ -142,7 +142,7 @@
 secure_chroot_dir=/var/run/vsftpd/empty
 #
 # This string is the name of the PAM service vsftpd will use.
-pam_service_name=vsftpd
+pam_service_name=ftp
 #
 # This option specifies the location of the RSA certificate to use for SSL
 # encrypted connections.
@@ -152,4 +152,8 @@

 #
 # Uncomment this to indicate that vsftpd use a utf8 filesystem.
-#utf8_filesystem=YES
+utf8_filesystem=YES
+userlist_enable=YES
+userlist_deny=NO
+userlist_file=/etc/vsftpd.user_list
+allow_writeable_chroot=YES

懒得手动改,可以将上面的patch 文件保存到机器上,然后使用

$ cd /
$ sudo  patch -p0 < [patch文件路径]

这样就将配置更新了。

创建登录用户

#先创建ftp目录
$ sudo mkdir /home/ftpdir
#添加用户
$ sudo useradd -d /home/ftpdir -s /bin/bash ftpuser
#设置用户密码
$ sudo passwd ftpuser
#设置ftp目录用户权限
$ sudo chown ftpuser:ftpuser /home/ftpdir

添加vsftpd 登录用户

#新建文件/etc/vsftpd.user_list,用于存放允许访问ftp的用户:
$ sudo touch /etc/vsftpd.user_list 
$ sudo vim /etc/vsftpd.user_list

在/etc/vsftpd.user_list中添加允许登录ftp 的用户
ftpuser

添加vsftpd登录用户对目录树的权限

#新建文件/etc/vsftpd.chroot_list,设置可列出、切换目录的用户:
$ sudo touch /etc/vsftpd.chroot_list 
$ sudo vim /etc/vsftpd.chroot_list

在/etc/vsftpd.chroot_list 设置可列出、切换目录的用户
ftpuser

重启 vsftpd 服务

$ sudo service vsftpd restart

验证ftp服务

ubuntu 使用vsftpd 创建FTP服务(用户名密码登录,限制列出目录)_ubuntu


标签:FTP,chroot,vsftpd,sudo,list,etc,ubuntu,YES
From: https://blog.51cto.com/u_13912333/6879045

相关文章

  • Ubuntu apt 安装 nodejs
    安装nodejs在windows下,都是到Nodejs官方网站上下载压缩包。然后在环境变量中配置Nodejs的环境变量,但是到了Ubuntu下这种情况可能会改变,因为有强大的APT包管理器。所以我们要做的就是两件事情,第一找到资源仓库,第二安装所需要的资源。Step1Nodejs的APT仓库#先安装Python的软件......
  • Ubuntu Netplane balancing algorithm modes
    目录起因前提知识配置步骤参考文档说明起因因为机房服务器新部署,双网卡服务器。一般来说业务系统的要求配置都是双网线然后配置bond0,主从轮番使用网卡就行。这次不太一样,网络管理员要求使用boud4模式,也是链路融合,所以就查询了一下资料没发现了bond的配置方式,很奇特的是,和Centos不......
  • ubuntu安装mysql
      要在Ubuntu上安装MySQL,请按照以下步骤进行操作:打开终端:您可以按下Ctrl+Alt+T键打开终端,或者在应用程序菜单中搜索"终端"并打开。运行以下命令以更新软件包列表:Copysudoaptupdate通过运行以下命令安装MySQL服务器:Copysudoaptinstallmysql......
  • ubuntu22 redis 6.0.16
    一、安装下载安装更新软件库aptupdate下载安装sudoaptinstallredis-server-y查看是否运行sudosystemctlstatusredis-serverActive:active(running)sinceFri2023-05-1912:56:25CST;3min19sago测试redis-cli127.0.0.1:6379>keys*(emptyarray)exit二、配置配......
  • Ubuntu修改网卡配置
    操作环境:Ubuntu20.04.6LTS本人这台Ubuntu情况特殊,不能用较新的netplan来更改网卡配置,所以用修改interfaces的方法,操作过程如下:1、编辑该文档sudovi/etc/network/interfaces简单介绍一下:进入vi(文档编辑器)页面后,按“i”进入insert(输入)模式即可进行编辑。......
  • ubuntu22 mysql 8.0.33
    一、安装下载安装sudoaptinstallmysql-server-y查看版本mysql--versionmysqlVer8.0.33-0ubuntu0.22.04.2forLinuxonx86_64((Ubuntu))查看是否运行sudosystemctlstatusmysqlActive:active(running)sinceThu2023-05-1819:53:54CST;2h41minago修改密码进......
  • FTPBox Starter
    目录FTPBox是什么?Maven依赖配置单主机配置多主机配置多Host使用手册使用APIuploaddownloadexistslistexecuteexecuteWithoutResultGithub:https://github.com/lihewei7/ftpbox-spring-boot-starterGitee:https://gitee.com/lihewei7/ftpbox-spring-boot-starterFTPBox是什么......
  • ubuntu下用vs code管理gitee仓库,上传、下载代码,基于git
    一、下载安装git下载:sudoapt-getinstallgit卸载:sudoapt-getremovegit下载之前可以先:sudoapt-getupgrade/update一下二、配置本地信息配置本地信息,相当于是设置提交代码时的用户信息。gitconfig[--global]user.name"[name]"gitconfig[--global]use......
  • linux XFTP权限不足、上传失败
    问题使用XFTP上传失败一、权限不够前提:使用root用户创建了/opt/jdk然后使用普通的user登录连接ftp但是user对jdk文件对并没有w的权限,因此会上传失败解决办法使用root登录ftp增加ftp的权限chmodo+w/opt/jdk......
  • 正点原子Ubuntu入门015---shell脚本入门
    一、什么是shell脚本shell脚本类似于Windows的批处理文件,shell脚本就是将连续执行的命令写成一个文件shell脚本提供数组、循环、条件判断功能。shell脚本一般是Linux运维或者系统管理员要掌握的,作为嵌入式开发人员,只需要掌握基本的命令即可二、shell脚本的写法shell脚......