ubuntu服务器安装FTP服务

ubuntu服务器安装FTP服务

[TOC]

参考教程

[ubuntu16.04搭建ftp服务器

一、实验环境

  • 腾讯云学生机64位ubuntu16.04
  • 腾讯云已备案解析域名
  • 使用腾讯云webshell登入服务器

二、安装配置FTP

ftp服务器相比seafile网盘就简单很多,主要问题出在配置上

下载ftp

sudo apt-get update
sudo apt-get install vsftpd

安装完成,输入vsftpd -version查看版本,可以的话说明安装成功。

配置环境

打开配置文件vim /etc/vsftpd.conf

将里面的内容覆盖成如下的内容:

listen=NO
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 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

# 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 20 (ftp-data).
connect_from_port_20=YES

# 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 fully customise the login banner string:
ftpd_banner=Welcome to FTP service.

# 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

# 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
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

里面有几个重要的参数

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

以及

pam_service_name=ftp原配置中为vsftpd,ubuntu用户需要更改成ftp

其他有兴趣的可以去查看其他人的相关教程有介绍

新建用户

sudo useradd -m -s /bin/bash username -g ftp
sudo passwd seafile

然后进入用户,

su username
cd ~

建立ftp访问的文件pub,并给权限

mkdir pub
chmod 777 -R pub

限制用户username只能通过ftp登陆,而不能直接登陆服务器,可以返回ubuntu账户或者root账户操作

sudo  usermod -s /sbin/nologin username

新建/etc/vsftpd.chroot_list,并将username加入进去

之后启动或者重启vsftpd即可

 /etc/init.d/vsftpd restart
 /etc/init.d/vsftpd start

然后在文件管理器那边输入 ftp:www.你的域名,然后输入用户名和密码。

大功告成!

原文地址:https://www.cnblogs.com/Anani-leaf/p/8799018.html

时间: 2024-08-25 17:23:51

ubuntu服务器安装FTP服务的相关文章

ubuntu 开启 ftp 服务 | mingming-killer

body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI",Tahoma,Helvetica,Sans-Serif,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLiU,serif; font-size: 10.5pt; line-height: 1.5;

如何在Ubuntu 搭建 FTP 服务?

如何搭建 FTP 服务? 首先创建一个 Linux 云服务器(以 Ubuntu 为例),并在云计算防火墙中打开 tcp 21 下行,并"更新规则".下面简单介绍下安装 vsftpd 和 proftpd 的注意事项 vsftpd 安装 apt-get install vsftpd 修改配置文件 /etc/vsftpd.conf 后,重启生效 service vsftpd restart 如果您的 ftp client 位于 NAT 之后,ftp server 必须启用 passive m

ubuntu 开启ftp服务

一. 检查是否已安装 vsftpd vsftpd -v 二. 安装 vsftpd apt-get install vsftpd 三.  检查是否已安装好 vsftpd vsftpd -v systemctl status vsftpd.service 四.先查看iptables设置: #iptables -nL 防护墙方法: https://i.cnblogs.com/EditPosts.aspx?opt=1 五. 查看端口情况 iptables -nL 六. 搭建FTP服务 加载ip_conn

ubuntu 安装 ftp服务

1. 更新源列表    ---> sudo apt-get update 2. 安装vsftpd ---> sudo apt-get install vsftpd    (安装) ---->  sudo service vsftpd start    (启动) 3 . 新建"/home/uftp"目录作为用户主目录  (用户 uftp) ---> sudo mkdir /home/uftp ---> sudo ls /home    (查看目录有没有生成)

ubuntu开启ftp服务

首先再防火墙中开启21和20端口 iptables -A INPUT -p tcp --dport 21 -j ACCEPT iptables -A INPUT -p tcp --dport 20 -j ACCEPT iptables -A OUTPUT -p tcp --sport 21 -j ACCEPT iptables -A OUTPUT -p tcp --sport 20 -j ACCEPT 如果本地有vsftpd服务那么可以直接使用,如果没有的话先安装,再配置,再重启服务: 安装:

为Ubuntu安装FTP服务

打开"终端窗口",输入"sudo apt-get update"-->回车-->"输入当前登录用户的管理员密码"-->回车,就可以了.如果不运行该命令,直接安装vsftpd,会出现"有 几个软件包无法下载,您可以运行apt-get update------"的错误提示,导致无法安装. 打开"终端窗口",输入"sudo apt-get install vsftpd"--&

Ubuntu下的FTP服务的安装和设置

一 安装vsftpd 在安装前vsftpd,先更新apt-get下载的数据源输入如下命令: sudo apt-get update 然后安装vsftpd sudo apt-get install vsftpd 二 增加FTP账户 新建ubuntu账户ftp. sudo useradd -m ftp sudo passwd ftp 如果安装好vsftpd服务后在/home目录下有ftp目录,那么就忽略创建ftp目录命令,否则就输入以下命令,新建一个ftp目录并授权. mkdir /home/ftp

Ubuntu下安装FTP服务及使用(VSFTPD详细设置)(二)

vsftpd 作为一个主打安全的FTP服务器,有很多的选项设置.下面介绍了vsftpd的配置文件列表,而所有的配置都是基于vsftpd.conf这个配置文件 的.本文将提供完整的vsftpd.conf的中文说明.学习本文的内容将有助于你初步了解vsftpd的配置文件,但针对具体情况还需要制定具体的配置 方法. Vsftpd的配置文件: /etc/vsftpd/vsftpd.conf 主配置文件 /usr/sbin/vsftpd Vsftpd 的主程序 /etc/rc.d/init.d/vsftp

Ubuntu下安装FTP服务及使用(以VSFTPD为例)

(一)安装与配置 (1)       安装vsftpd $sudo apt-get install vsftpd 这里会提示无法创建/home/ftp目录,手动创建一个 $sudo mkdir /home/ftp 如果提示已创建目录就不用理它了 (2)       编辑配置文件/etc/vsftpd.conf $sudo gedit /etc/vsftpd.conf 也可以使用vi 主要配置: 将local_enable=YES前的#去掉,使其可用,表示允许本地用户登录: 将anonymous_