建议收藏 | Ubuntu16.04 ftp服务器安装+配置

admin 2021年3月1日13:07:02评论147 views字数 4336阅读14分27秒阅读模式

请点击上面 建议收藏 | Ubuntu16.04 ftp服务器安装+配置 一键关注!

内容来源:CSDN

建议收藏 | Ubuntu16.04 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 //显示连接成功

建议收藏 | Ubuntu16.04 ftp服务器安装+配置

「天億网络安全」 知识星球 一个网络安全学习的星球!星球主要分享、整理、原创编辑等网络安全相关学习资料,一个真实有料的网络安全学习平台,大家共同学习、共同进步!

知识星球定价:199元/年,(服务时间为一年,自加入日期顺延一年)。

如何加入:扫描下方二维码,扫码付费即可加入。

加入知识星球的同学,请加我微信,拉您进VIP交流群!

建议收藏 | Ubuntu16.04 ftp服务器安装+配置

朋友都在看

▶️等保2.0丨2021 必须了解的40个问题

▶️等保2.0 三级 拓扑图+设备套餐+详解

▶️等保2.0 二级 拓扑图+设备套餐+详解

▶️等保2.0 测评  二级系统和三级系统多长时间测评一次?

▶️等保2.0系列安全计算环境之数据完整性、保密性测评

▶️等保医疗|全国二级、三乙、三甲医院信息系统安全防护设备汇总

▶️国务院:不符合网络安全要求的政务信息系统未来将不给经费

▶️等级保护、风险评估和安全测评三者的区别

▶️分保、等保、关保、密码应用对比详解

▶️汇总 | 2020年发布的最重要网络安全标准(下载)

天億网络安全

【欢迎收藏分享到朋友圈,让更多朋友了解网络安全,分享也是一种美德!】

建议收藏 | Ubuntu16.04 ftp服务器安装+配置

↑↑↑长按图片识别二维码关註↑↑↑


欢迎扫描关注【天億网络安全】公众号,及时了解更多网络安全知识

本文始发于微信公众号(天億网络安全):建议收藏 | Ubuntu16.04 ftp服务器安装+配置

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年3月1日13:07:02
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   建议收藏 | Ubuntu16.04 ftp服务器安装+配置http://cn-sec.com/archives/277583.html

发表评论

匿名网友 填写信息