ubuntu16.04ftp服务器安装+配置(代码片段)

somebot somebot     2022-12-02     255

关键词:

最近在配置百度云服务器和阿里云服务器,需要把本地的代码和资料上传到服务器,运行测试。

于是就需要自己搭建一个FTP服务。

 

ftp服务器安装与配置


1. ftp服务端的安装

如果之前配置过ftp服务器的还是之后配置的服务器,无法启动服务,那么基本是配置出现了错误,那么可先完全卸载后再进行安装。如果无法定位多半是镜像源的问题,请更换阿里源。

sudo apt-get update 
sudo apt-get install vsftpd
vsftpd --version     //检测是否安装
2. ftp服务端的配置
 vim /etc/vsftpd.conf    //编辑配置文件

修改vsftpd.conf文件如下:

listen=NO                 //是否开启监听ipv4和ipv6数据      
listen_ipv6=YES          //是否开启监听ipv6数据

# 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    //确认连接传输的端口号为20

# 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.  //在使用shell时登陆那么会发送欢迎语


# 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            //此处ubuntu的系统需要改为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       //编码统一为utf8编码,可以识别中文,防止乱码
 3. vftpd配置完成

添加设置ftpuser用户和访问目录


 1. 创建ftp用户组和用户
sudo groupadd ftpusers //创建ftpusers用户组
sudo useradd -m ftpuser_lxr//创建一个用户并且自动创建家目录为/home/ftpuser_lxr
(第二种方式:mkdir /home/ftpuser_lxr //先创建家目录sudo userad -d /home/ftpuser_lxr ftpuser_lxr //绑定这个家目录)
usermod -G ftpusers ftpuser_lxr //将这个新用户加入到ftpusers用户组中
sudo passwd ftpuser_lxr   //更改密码
mkdir /home/ftpuser_lxr/ftp  //为用户添加一个具有一定权限的文件夹
chmod 777 -R /home/ftpuser_lxr/ftp //新建一个pub目录用于存放文件,并且赋予全部权限
usermod -s /sbin/nologin username  //限制用户登录方式;限制用户username只能通过ftp登陆,而不能直接登陆服务器
2.将该用户加入vsftpd.chroot_list白名单中
mkdir /etc/vsftpd.chroot_list
vim vsftpd.chroot_list

该文件内容如下:

#白名单
ftpuser_lxr
3.开启并重启vsftpd的服务

systemctl start vsftpd或者service vsftpd start 
systemctl restart vsftpd或者service vsftpd restart


测试

方法一:

打开浏览器,在地址栏输入:ftp://ip_addresss

方法二:

 在ubuntu中使用shell输入:ftp ip_address

方法三:

 在windows中在文件管理器地址栏输入:ftp://ip_addresss,该方式可以上传下载文件

方法四:

 在windows中使用cmd输入:ftp://ip_addresss //显示连接成功

 

 

 

xiaomaprostringcloud生产环境安装ubuntu16.04版本(代码片段)

XiaoMaPro、Stringcloud、生产环境安装Ubuntu16.04版本安装ssh使用apt安装openssh服务sudoapt-getinstallopenssh-server或sudoapt-getinstallssh进行安装,安装完成查看是否已经启动,在终端输入ps-e|grepsshd在终端将会看到类似这样的输出:3665... 查看详情

linux运维:rsync同步数据(ubuntu16.04+windows10)(代码片段)

rsync同步数据-环境:Linux(ubuntu16.04)+windows10Linux:安装sudoapt-getinstallrsyncrsync--version查看是否已安装,并查看版本配置主要三个配置文件.默认不存在(/etc/..)①rsyncd.conf②rsyncd.secrets③rsyncd.motd(rsync服务器信息)2.1创建配置文件cd/etcmkdirrsync 查看详情

text配置服务ubuntu16.04(代码片段)

查看详情

ubuntu16.04下安装配置nodejs及npm(代码片段)

官网下载ubuntu对应的二进制文件(LinuxBinaries(x64)这一行)https://nodejs.org/en/download/解压并安装```$tarzxvfnode-v0.10.24.tar.gz#解压后进入对应目录$sudochmod-R755node$sudo./configure$sudomake$sudomakeinstall```大功告成```$node-v$npm- 查看详情

docker1.12.3在ubuntu16.04上的安装和配置(代码片段)

Docker在Ubuntu上的安装和配置以下安装过程只在Ubuntu16.04x64上做过测试。我们建议安装的是Docker官方维护的版本,而不是Ubuntu官方软件仓库中的版本。一般Ubuntu官方维护的版本会比Docker官方维护的版本低两个版本号。如果你不... 查看详情

sh在ubuntu16.04上安装mariadb服务器(代码片段)

查看详情

ubuntu16.04搭建gitlab(代码片段)

...置gitlab三、使用gitlab四、踩坑记录工作中遇到需要在远端服务器搭建gitlab,耗时4天,踩坑无数,特此开个虚拟机再次搭建一次gitlab并记录供以后参考!背景:为保证服务器安全,远端服务器在内网,本... 查看详情

ubuntu16.04+pycharm+spark运行环境配置(代码片段)

0.安装PyCharm和spark     下载pycharm  http://www.jetbrains.com/pycharm/     下载spark         http://spark.apache.org/      ps:在安装pycharm前系统需要有java环境1.安装py4j      $sudopipinstallpy4j2.配置pycharm      在Run/Deb 查看详情

sh在ubuntu16.04中,lamp堆栈,sublime,appache2配置更改,wpcli安装,节点安装(代码片段)

查看详情

ubuntu16.04rabbitmq安装与运行(安装篇)(代码片段)

...优缺点后,这里为了深入学习rabbitmq,我在自己的腾讯云服务器上也搭建了一套环境。准备工作一台服务器:UbuntuServer16 查看详情

ubuntu16.04怎样配置tftp服务器

参考技术Asudoapt-getinstalltftpd-hpasudoapt-getinstalltftp-hpa(需要客户端安装) 查看详情

linux系统知识汇总(代码片段)

...缓存cacheubuntu手动释放缓存(清理内存cache)2JupyterLab2.1远程服务器访问Ubuntu服务器JupyterNotebook配置与远程连接2.2多kernel设置Jupyterlab安装及多kernel配置2.3JuputerLab扩展JupyterLab插件3显卡驱动3.1cudnn安装Ubuntu16.04上安装cudnn5.1详细教程3.2CUD... 查看详情

ubuntu16.04安装teamviewer(代码片段)

...http://www.cnblogs.com/wmr95/p/7574615.html 有时需要远程控制ubuntu系统的电脑,Teamviewer在linux下也可以进行安装,大致看了下向日葵在linux下配置好像比较麻烦,而且Teamviewer远程控制的流畅性一直不错,就选择安装Teamviewer。  下面... 查看详情

ftp(filetransferprotocol)搭建文件传输服务器vsftp(vsftpd)(ftp和sftp区别)(未完成)(代码片段)

...SFTP都不知道?快来get新技能吧!vsftpd,这类服务器对用户认证和权限控制比较简单,更注重安全型和速度。支持虚拟用户,但用户权限依赖于文件的系统权限,不支持针对目录的权限配置,在配置依赖... 查看详情

markdown在ubuntu16.04服务器上安装prometheus2.x.(代码片段)

查看详情

ubuntu16.04升级openssh(代码片段)

参考:Ubuntu16.04升级Openssh8.8P1Ubuntu16更新openssh8.81.安装Telent防止ssh出问题无法远程服务器服务器上安装telent服务端apt-getinstallopenbsd-inetdtelnetdtelnet/etc/init.d/openbsd-inetdrestart#启动服务netstat-anpt|grep23#查看telnet 查看详情

在 Ubuntu 16.04 上重新安装 MySQL 5.7 服务器的问题

】在Ubuntu16.04上重新安装MySQL5.7服务器的问题【英文标题】:IssuesonreinstallingMySQL5.7serveronUbuntu16.04【发布时间】:2017-05-0514:53:47【问题描述】:我的服务器在Ubuntu16.04上运行我的MySQL配置有问题,所以我决定清理并重新安装MySQL服务... 查看详情

Ubuntu 16.04 我卸载了 apache2 但现在无法重新安装

...】:2019-05-1221:26:14【问题描述】:我在我设置的ubuntu16.04服务器上遇到了问题。我怀疑我在最初安装和配置apache2时犯了许多错误,因为它的行为与正常情况不同。我决定完全卸载apache2,包括删除配置文件,以便进行 查看详情