FTP服务器是在计算机上运行的软件,允许用户使用FTP客户端将文件上传到服务器和从服务器下载文件。它通过网络将文件从服务器计算机传输到客户端。请记住,vsftpd 是一个非常基本和轻量级的 FTP 服务器,建议仅将其用于简单的文件传输需求。
在 Ubuntu 22.04 LTS 上安装 FTP 服务器 Jammy 水母
第 1 步。首先,通过在终端中运行以下命令,确保所有系统软件包都是最新的。apt
<span class="pln">sudo apt update sudo apt upgrade</span>
第 2 步。在 Ubuntu 22.04 上安装 FTP 服务器。
默认情况下,vsftpd(非常安全的FTP守护程序)在Ubuntu 22.04基本存储库上不可用。现在运行以下命令,将最新的稳定版本的 vsftpd 安装到您的 Ubuntu 系统中:
<span class="pln">sudo apt install vsftpd</span>
安装 vsftpd 后,以下命令可用于停止、启动和启用服务器服务,使其在服务器启动时始终启动:
<span class="pln">sudo systemctl start vsftpd sudo systemctl enable vsftpd sudo systemctl status vsftpd</span>
第 3 步。在 Ubuntu 22.04 上配置 FTP 服务器。
我们需要将其配置为在我们的系统上正常工作。vsftpd 的配置文件位于 。我们可以使用最喜欢的文本编辑器(如 nano)编辑此文件:/etc/vsftpd.conf
<span class="pln">nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">vsftpd</span><span class="pun">.</span><span class="pln">conf</span>
并添加以下文件:
<span class="pln">listen</span><span class="pun">=</span><span class="pln">NO listen ipv6</span><span class="pun">=</span><span class="pln">YES anonymous_enable</span><span class="pun">=</span><span class="pln">NO local_enable</span><span class="pun">=</span><span class="pln">YES write_enable</span><span class="pun">=</span><span class="pln">YES local_umask</span><span class="pun">=</span><span class="lit">022</span><span class="pln"> dirmessage_enable</span><span class="pun">=</span><span class="pln">YES use_localtime</span><span class="pun">=</span><span class="pln">YES xferlog_enable</span><span class="pun">=</span><span class="pln">YES connect_from_port_20</span><span class="pun">=</span><span class="pln">YES chroot_local_user</span><span class="pun">=</span><span class="pln">YES secure_chroot_dir</span><span class="pun">=</span><span class="str">/var/</span><span class="pln">run</span><span class="pun">/</span><span class="pln">vsftpd</span><span class="pun">/</span><span class="pln">empty pam_service_name</span><span class="pun">=</span><span class="pln">vsftpd rsa_cert_file</span><span class="pun">=</span><span class="str">/etc/</span><span class="pln">ssl</span><span class="pun">/</span><span class="pln">certs</span><span class="pun">/</span><span class="pln">ssl</span><span class="pun">-</span><span class="pln">cert</span><span class="pun">-</span><span class="pln">snakeoil</span><span class="pun">.</span><span class="pln">pem rsa_private_key_file</span><span class="pun">=</span><span class="str">/etc/</span><span class="pln">ssl</span><span class="pun">/</span><span class="kwd">private</span><span class="pun">/</span><span class="pln">ssl</span><span class="pun">-</span><span class="pln">cert</span><span class="pun">-</span><span class="pln">snakeoil</span><span class="pun">.</span><span class="pln">key ssl_enable</span><span class="pun">=</span><span class="pln">NO pasv_enable</span><span class="pun">=</span><span class="typ">Yes</span><span class="pln"> pasv_min_port</span><span class="pun">=</span><span class="lit">10000</span><span class="pln"> pasv_max_port</span><span class="pun">=</span><span class="lit">10100</span><span class="pln"> allow_writeable_chroot</span><span class="pun">=</span><span class="pln">YES</span>
保存并关闭该文件,然后通过运行以下命令重新启动 vsftpd 服务:
<span class="pln">sudo systemctl restart vsftpd</span>
第 4 步。配置防火墙。
现在,我们使用FTP服务器设置了一个简单防火墙(UFW),以允许公共访问默认端口。20,21,10000:10100
<span class="pln">sudo ufw allow </span><span class="typ">OpenSSH</span><span class="pln"> sudo ufw allow </span><span class="kwd">from</span><span class="pln"> any to any port </span><span class="lit">20</span><span class="pun">,</span><span class="lit">21</span><span class="pun">,</span><span class="lit">10000</span><span class="pun">:</span><span class="lit">10100</span><span class="pln"> proto tcp sudo ufw enable</span>
第5步。创建用于 FTP 访问的新用户。
为了访问FTP服务器,我们需要创建一个专门用于FTP访问的新用户。要创建新用户,请运行以下命令:
<span class="pln">$ sudo useradd </span><span class="pun">-</span><span class="pln">m ranty $ sudo passwd rantna </span><span class="typ">New</span><span class="pln"> password</span><span class="pun">:</span> <span class="typ">Retype</span> <span class="kwd">new</span><span class="pln"> password</span><span class="pun">:</span><span class="pln"> passwd</span><span class="pun">:</span><span class="pln"> password updated successfully</span>
感谢您使用本教程在 Ubuntu 22.04 LTS Jammy Jellyfish 系统上安装 FTP 服务器。有关其他帮助或有用信息,我们建议您查看 vsftpd 官方网站。