Ubuntu系统部署FTP服务器

Ubuntu系统部署FTP服务器

1,安装FTP

  • 执行以下命令安装ftp服务
sudo apt-get install vsftpd
  • 检查是否安装成功
vsftpd -v
  • 出现版本信息表示安装成功

在这里插入图片描述

2,编辑配置文件

  • 使用下面命令进入配置文件
    注: 这里笔者使用的vim编辑器,童鞋们也可使使用其他的编辑器
sudo vim /etc/vsftpd.conf
  • (1)开启以下功能:

  • write_enable=YES:表示允许对FTP服务器执行写操作,包括上传、删除和重命名文件等操作。

# Uncomment this to enable any form of FTP write command.
write_enable=YES

  • chroot_local_user=YES:这个配置指定了只有本地用户(即系统用户)才会被限制在其主目录中。如果设置为YES,那么FTP用户将被限制在其主目录下,无法访问根目录以外的文件或目录。

  • chroot_list_enable=YES:这个配置指定了是否启用chroot_list_file中列出的用户列表的chroot限制。

  • chroot_list_file=/etc/vsftpd.chroot_list:这个配置指定了包含需要被chroot限制的用户列表的文件路径。如果chroot_list_enable设置为YES,那么在chroot_list_file中列出的用户将被限制在其主目录中。

# 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

  • (2)加入根目录
    这句配置指定了vsftpd的根目录为/home/python/ftpfile。这意味着当用户连接到ftp服务器时,他们将被限制在这个目录下,无法访问根目录以外的文件或目录。
local_root=/home/python/ftpfile

注:下面是我的配置文件(完整)开启功能

#
# Run standalone?  vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=NO
#

# 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
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 20 (ftp-data).
connect_from_port_20=YES
# (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
# 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=vsftpd
#
# 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
local_root=/home/python/ftpfile

3,添加用户及密码

  • 1,给自己的系统添加新用户(方便演示ftp使用)
    lisi是我取的用户名,随便取记住就行
sudo useradd -m lisi
  • 2,配置密码
    输入下面命令会让你输入密码
sudo passwd lisi

在这里插入图片描述

4,在chroot_list中添加用户

sudo vim /etc/vsftpd.chroot_list

在该文件加入lisi
在这里插入图片描述

5,重启服务

sudo /etc/init.d/vsftpd restart

出现以下信息就ok了
在这里插入图片描述

测试

  • 使用ifconfig命令找到自己主机的ip地址
  • 使用ftp ip地址命令
ftp 192.168.XX.XX
  • 然后输入配置好的用户名和密码,出现ftp>就成功访问了。
    在这里插入图片描述
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值