Ubuntu 18.04 安装 vsftpd

Ubuntu 18.04 安装 vsftpd

  • 系统版本
# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04 LTS
Release:	18.04
Codename:	bionic
  • 安装 vsftpd
# apt install -y vsftpd
  • 查看 vsftpd 运行状态
# systemctl status vsftpd
● vsftpd.service - vsftpd FTP server
   Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-09-29 23:29:58 CST; 4min 15s ago
 Main PID: 59338 (vsftpd)
    Tasks: 1 (limit: 13516)
   CGroup: /system.slice/vsftpd.service
           └─59338 /usr/sbin/vsftpd /etc/vsftpd.conf

9月 29 23:29:58 user-Tecal-RH2285-V2-12L systemd[1]: Starting vsftpd FTP server...
9月 29 23:29:58 user-Tecal-RH2285-V2-12L systemd[1]: Started vsftpd FTP server.
  • 防火墙设置
# ufw allow 20/tcp
# ufw allow 21/tcp
# ufw allow 40000:50000/tcp
# ufw  allow 990/tcp
# ufw allow ssh
  • 添加用户
# adduser ftpuser
# systemctl restart  sshd
# mkdir /home/ftpuser/ftp
# chown nobody:nogroup /home/ftpuser/ftp/
# chmod a-w /home/ftpuser/ftp/
# mkdir /home/ftpuser/ftp/files
# chown ftpuser:ftpuser /home/ftpuser/ftp/files/
# cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
  • 配置文件 cat /etc/vsftpd.conf | grep -v ^#
listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO

force_dot_files=YES
pasv_min_port=40000
pasv_max_port=50000
user_sub_token=$USER
local_root_/home/$USER/frp
  • 重启 vsftpd
# systemctl restart vsftpd

  • 安装 vsftpd
# apt install -y vsftpd
  • 创建用户
# adduser `
  • 配置文件$ cat /etc/vsftpd.conf | grep -v ^#
listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
allow_writeable_chroot=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO
  • 重启服务
# systemctl restart vsftpd
  • 报错
    状态: 尝试连接“ECONNREFUSED - 连接被服务器拒绝”失败。
    错误: 无法连接到服务器
  • 选择 SFTP 协议
    在这里插入图片描述

参考:

  1. 阿里云主机(Ubuntu 16.04版)用vsftpd搭建ftp服务器步骤分享

你可能感兴趣的:(linux)