ubuntu ftp服务器
In this tutorial, let’s learn how to install FTP server on Ubuntu. FTP or File Transfer Protocol is a protocol used to transfer files between two remote servers over the network.
在本教程中,让我们学习如何在Ubuntu上安装FTP服务器。 FTP或文件传输协议是用于在网络上的两个远程服务器之间传输文件的协议。
Just like HTTP is used to transfer data over the network through web browsers, FTP is commonly found being used by command-line users.
就像HTTP用于通过Web浏览器在网络上传输数据一样,FTP通常被命令行用户使用。
When you wish to install FTP server on Ubuntu, you have got a variety of open source FTP servers to choose from. However, for this tutorial, we will install the vsftpd (Very Secure FTP Daemon) server on our system.
当您希望在Ubuntu上安装FTP服务器时,您可以选择多种开源FTP服务器。 但是,对于本教程,我们将在系统上安装vsftpd(非常安全的FTP守护程序)服务器。
This tutorial was made with an Ubuntu 18.04 running system. However, the same instructions will work on Ubuntu 16.04 and Debian based distributions like Elementary OS, Linux Mint and Debian.
本教程是使用Ubuntu 18.04运行系统制作的。 但是,相同的说明也适用于Ubuntu 16.04和基于Debian的发行版,例如Elementary OS,Linux Mint和Debian。
You would also need a non-root user with sudo privileges to follow this tutorial where we install FTP server on Ubuntu.
您还需要一个具有sudo特权的非root用户来遵循本教程,在本教程中,我们在Ubuntu上安装FTP服务器。
To install FTP server on Ubuntu, you don’t need to download anything. This is because the FTP server package comes with the default Ubuntu repository. The package that we’ll use is named vsftpd and can be accessed using the apt command.
要在Ubuntu上安装FTP服务器,您无需下载任何内容。 这是因为FTP服务器软件包随附于默认的Ubuntu存储库。 我们将使用的软件包名为vsftpd ,可以使用apt命令进行访问。
Before we begin to install FTP server on Ubuntu, we need to update our default repositories using the apt package management service.
在开始在Ubuntu上安装FTP服务器之前,我们需要使用apt软件包管理服务更新默认存储库。
To do this, you need to open the terminal on your Ubuntu system and type the following.
为此,您需要在Ubuntu系统上打开终端并输入以下内容。
sudo apt update && sudo apt upgrade
These commands update the Ubuntu repositories with the latest available repositories for your system.
这些命令使用系统的最新可用存储库更新Ubuntu存储库。
Now, this ensures that we will get the latest version of the vsftpd package when we install the FTP server on our system.
现在,这确保了在系统上安装FTP服务器时我们将获得最新版本的vsftpd软件包。
Now that we understand what an FTP server does, and have covered the prerequisites, it is time to install FTP server on our system. To do so, you need to follow the following steps.
既然我们了解了FTP服务器的功能,并且已经满足了先决条件,那么现在该在我们的系统上安装FTP服务器了。 为此,您需要遵循以下步骤。
Now that we have the desired repository, we can proceed with the tutorial. We will use the apt package management service to install FTP server on Ubuntu.
现在我们有了所需的存储库,我们可以继续进行本教程。 我们将使用apt软件包管理服务在Ubuntu上安装FTP服务器。
To do so, we enter the following in our terminal. You might be prompted to enter your user password to continue.
为此,我们在终端中输入以下内容。 可能会提示您输入用户密码以继续。
sudo apt install vsftpd
When you enter this command in your command line, this is what you should expect to see as the output on your screen.
当您在命令行中输入此命令时,这就是您期望在屏幕上看到的输出。
This command will tell the apt package manager to fetch the vsftpd package from our system repository.
此命令将告诉apt软件包管理器从我们的系统信息库中获取vsftpd软件包。
Once we install FTP server on Ubuntu, We can verify this by asking the terminal for the status of our vsftpd service. To do so, we enter this in our terminal.
在Ubuntu上安装FTP服务器后,我们可以通过询问终端vsftpd服务的状态来验证这一点。 为此,我们在终端中输入。
sudo systemctl status vsftpd
This will fetch the details of the current status of the FTP server on our system. If we made no mistakes, the current status of our vsftpd service should be ‘running’ as seen in the screenshot above.
这将获取我们系统上FTP服务器当前状态的详细信息。 如果我们没有记错的话,我们的vsftpd服务的当前状态应该是“正在运行”,如上面的屏幕快照所示。
When you install FTP server on Ubuntu, you need to configure it before it can be used.
在Ubuntu上安装FTP服务器时,需要对其进行配置才能使用。
Before we make any custom configurations, it is a recommended practice to create a copy of the default vsftpd configuration file as a backup in case we want to reset our configuration.
在进行任何自定义配置之前,建议做法是创建默认vsftpd配置文件的副本作为备份,以防我们想重置配置。
This can be done using the cp command as shown below.
可以使用cp命令完成此操作,如下所示。
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf_backup
Now that we have a backup, we can start customizing the vsftpd configuration file. Let’s open the configuration file using the nano editor. You need to use this command to do so.
现在我们有了备份,我们可以开始自定义vsftpd配置文件了。 让我们使用nano编辑器打开配置文件。 您需要使用此命令。
sudo nano /etc/vsftpd.conf
Now we edit the configuration file to make necessary changes. The below table contains all the edits we make in this tutorial and what they do.
现在,我们编辑配置文件以进行必要的更改。 下表包含我们在本教程中所做的所有编辑及其作用。
Edit | Result |
anonymous_enable=NO local_enable=YES |
These block access for anonymous users, while enabling local users to access the FTP server. |
write_enable=YES | This allows changes to the filesystem when you upload or delete something through the FTP server. |
chroot_local_user=YES | This prevents a user from accessing files beyond their home directory. |
user_sub_token=$USER local_root=/home/$USER/ftp |
When chroot is enabled, vsftpd doesn’t allow uploads to prevent security risks. This creates an ftp directory in the user home to serve as the chroot. Later, we can create a new writable directory for the uploads. |
pasv_min_port=30000 pasv_max_port=31000 |
This assigns the ports between the range 30000 and 31000 for passive FTP connections. |
编辑 | 结果 |
onymous_enable =否 local_enable =是 |
这些阻止匿名用户访问,同时允许本地用户访问FTP服务器。 |
write_enable = YES | 通过FTP服务器上载或删除某些内容时,这允许更改文件系统。 |
chroot_local_user =是 | 这样可以防止用户访问其主目录之外的文件。 |
user_sub_token = $ USER local_root = / home / $ USER / ftp |
启用chroot时,vsftpd不允许上传以防止安全风险。 这将在用户主目录中创建一个ftp目录以用作chroot。 稍后,我们可以为上传创建一个新的可写目录。 |
pasv_min_port = 30000 pasv_max_port = 31000 |
这将在30000到31000范围内为被动FTP连接分配端口。 |
You can also specify certain users that can login while denying anyone who’s not on the list by creating a file “/etc/vsftpd.allowed_users” and adding the usernames here.
您还可以通过创建文件“ /etc/vsftpd.allowed_users ”并在此处添加用户名,来指定某些可以登录而拒绝不在列表中的用户的用户。
Once you have that set up, you can add the following lines to the configuration file:
设置完成后,可以将以下行添加到配置文件:
userlist_enable=YES
userlist_file=/etc/vsftpd.allowed_users
Now, we have been successful to install FTP server on Ubuntu and set some configurations.
现在,我们已成功在Ubuntu上安装FTP服务器并进行了一些配置。
It’s time to update the firewall settings using the ufw command so that our FTP server can listen through port numbers 20 and 21.
现在该使用ufw命令更新防火墙设置了,以便我们的FTP服务器可以侦听端口号20和21。
We will also open the port range 30000 to 31000, which we assigned for passive FTP connections. Enter these commands in your terminal.
我们还将打开为被动FTP连接分配的端口范围30000至31000。 在终端中输入这些命令。
sudo ufw allow 30000:31000/tcp
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
Now port 20 and 21 will work as listening ports for our FTP server. We will now check the status of ufw using the following command so that its rules are updated.
现在,端口20和21将用作FTP服务器的侦听端口。 现在,我们将使用以下命令检查ufw的状态,以便更新其规则。
sudo ufw status
Finally, we will use systemctl to restart the vsftpd service.
最后,我们将使用systemctl重新启动vsftpd服务。
sudo systemctl restart vsftpd
Now we are done with our quest to install FTP server on Ubuntu. Go ahead and connect to your FTP server
现在我们完成了在Ubuntu上安装FTP服务器的任务。 继续并连接到您的FTP服务器
While newer and faster protocols exist now, FTP remains relevant for legacy support and workplaces with highly specific requirements.
尽管现在存在更新更快的协议,但FTP仍然与传统支持和具有高度特定要求的工作场所相关。
It’s an important thing to keep in mind that FTP is an unencrypted network protocol by default.
请记住,默认情况下,FTP是未加密的网络协议,这一点很重要。
Hence, it is not a recommended protocol to be used for securely transferring data without sufficient safety mechanisms in place.
因此,在没有适当的安全机制的情况下,不建议将协议用于安全地传输数据。
This tutorial aimed to help you install FTP server on Ubuntu and set some basic configuration in place.
本教程旨在帮助您在Ubuntu上安装FTP服务器并设置一些基本配置。
翻译自: https://www.journaldev.com/38450/install-ftp-server-on-ubuntu
ubuntu ftp服务器