【前言】
最近新装的了电脑,创建了ubuntu虚拟机。为了方便文件传输,在安装好ubuntu后,先要建立ftp服务器。特地记录如下:
安装步骤如下:
1、使用sudo apt install vsftpd
lu@lu-virtual-machine:~$ sudo apt install vsftpd Reading package lists... Done Building dependency tree... Done Reading state information... Done The following NEW packages will be installed: vsftpd 0 upgraded, 1 newly installed, 0 to remove and 76 not upgraded. Need to get 123 kB of archives. After this operation, 326 kB of additional disk space will be used. Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/main amd64 vsftpd amd64 3.0.5-0ubuntu1 [123 kB] Fetched 123 kB in 2s (76.8 kB/s) Preconfiguring packages ... Selecting previously unselected package vsftpd. (Reading database ... 180825 files and directories currently installed.) Preparing to unpack .../vsftpd_3.0.5-0ubuntu1_amd64.deb ... Unpacking vsftpd (3.0.5-0ubuntu1) ... Setting up vsftpd (3.0.5-0ubuntu1) ... Created symlink /etc/systemd/system/multi-user.target.wants/vsftpd.service → /lib/systemd/system/vsftpd.service. Processing triggers for man-db (2.10.2-1) ...
2、启动服务器
lu@lu-virtual-machine:~$ service vsftpd start
3、新建目录/home/uftp作为用户主目录,同时授与权限777
lu@lu-virtual-machine:~$ sudo mkdir /home/uftp lu@lu-virtual-machine:/home$ sudo chmod 777 uftp lu@lu-virtual-machine:/home$ ls lu uftp
4、制定用户并设置该用户密码
lu@lu-virtual-machine:/home$ sudo useradd -d /home/uftp -s /bin/bash uftp lu@lu-virtual-machine:/home$ sudo passwd uftp New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: password updated successfully
5、将目录授权与uftp
lu@lu-virtual-machine:/home$ sudo chown uftp:uftp /home/uftp
6、新建文件/etc/vsftpd.user_list,用于存放允许访问ftp的用户:在其中添加用户uftp,并且保存退出:
lu@lu-virtual-machine:/home$ sudo vim /etc/vsftpd.user_list lu@lu-virtual-machine:/home$ cat /etc/vsftpd.user_list uftp
7、修改VSFTPD配置文件
修改:
打开注释 write_enable=YES
添加信息 userlist_file=/etc/vsftpd.user_list
添加信息 userlist_enable=YES
添加信息 userlist_deny=NO
修改完成后保存退出。
8、测试是否成功
在window的shell下面输入ftp 虚拟机IP,如下图所示
说明创建成功。打开ftp客户端,配置
连接后显示成功
致此ubuntu的vftpd服务创建成功,就可以实现方便的进行文件传输了。