ubuntu 使用vsftpd 創建FTP服務
vsftpd 是“very secure FTP daemon”的縮寫,安全性是它的一個最大的特點。vsftpd 是一個 UNIX 類操作系統上運行的服務器的名字,它可以運行在諸如 Linux、BSD、Solaris、 HP-UNIX等系統上面,是一個完全免費的、開放源代碼的ftp服務器軟件,支持很多其他的 FTP 服務器所不支持的特征。比如:非常高的安全性需求、帶寬限制、良好的可伸縮性、可創建虛擬用戶、支持IPv6、速率高等。
vsftpd是一款在Linux發行版中最受推崇的FTP服務器程序。特點是小巧輕快,安全易用。
摘自百度百科-vsftpd
ubuntu 安裝 vsftpd
$ sudo apt-get install vsftpd
使用apt安裝即可。
配置vsftpd
備份vsftpd.config
$ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig
編輯vsftpd.config
手動修改配置,根據下方的patch文件改一下。
$ sudo vim /etc/vsftpd.config
但是既然做了程序員就要懶一點,能自動就自動好了將配置好的文件與原始文件使用diff 生成的patch 文件,保存到本地,用patch命令更新即可。
1 --- /etc/vsftpd.conf.orig 2018-02-08 13:39:05.983282023 +0800 2 +++ /etc/vsftpd.conf 2018-02-10 11:14:15.584088172 +0800 3 @@ -28,11 +28,11 @@ 4 local_enable=YES 5 # 6 # Uncomment this to enable any form of FTP write command. 7 -#write_enable=YES 8 +write_enable=YES 9 # 10 # Default umask for local users is 077. You may wish to change this to 022, 11 # if your users expect that (022 is used by most other ftpd's) 12 -#local_umask=022 13 +local_umask=022 14 # 15 # Uncomment this to allow the anonymous FTP user to upload files. This only 16 # has an effect if the above global write enable is activated. Also, you will 17 @@ -67,11 +67,11 @@ 18 # 19 # You may override where the log file goes if you like. The default is shown 20 # below. 21 -#xferlog_file=/var/log/vsftpd.log 22 +xferlog_file=/var/log/vsftpd.log 23 # 24 # If you want, you can have your log file in standard ftpd xferlog format. 25 # Note that the default log file location is /var/log/xferlog in this case. 26 -#xferlog_std_format=YES 27 +xferlog_std_format=YES 28 # 29 # You may change the default value for timing out an idle session. 30 #idle_session_timeout=600 31 @@ -100,7 +100,7 @@ 32 #ascii_download_enable=YES 33 # 34 # You may fully customise the login banner string: 35 -#ftpd_banner=Welcome to blah FTP service. 36 +ftpd_banner=Welcome Lincoln Linux FTP Service. 37 # 38 # You may specify a file of disallowed anonymous e-mail addresses. Apparently 39 # useful for combatting certain DoS attacks. 40 @@ -120,9 +120,9 @@ 41 # the user does not have write access to the top level directory within the 42 # chroot) 43 #chroot_local_user=YES 44 -#chroot_list_enable=YES 45 +chroot_list_enable=YES 46 # (default follows) 47 -#chroot_list_file=/etc/vsftpd.chroot_list 48 +chroot_list_file=/etc/vsftpd.chroot_list 49 # 50 # You may activate the "-R" option to the builtin ls. This is disabled by 51 # default to avoid remote users being able to cause excessive I/O on large 52 @@ -142,7 +142,7 @@ 53 secure_chroot_dir=/var/run/vsftpd/empty 54 # 55 # This string is the name of the PAM service vsftpd will use. 56 -pam_service_name=vsftpd 57 +pam_service_name=ftp 58 # 59 # This option specifies the location of the RSA certificate to use for SSL 60 # encrypted connections. 61 @@ -152,4 +152,8 @@ 62 63 # 64 # Uncomment this to indicate that vsftpd use a utf8 filesystem. 65 -#utf8_filesystem=YES 66 +utf8_filesystem=YES 67 +userlist_enable=YES 68 +userlist_deny=NO 69 +userlist_file=/etc/vsftpd.user_list 70 +allow_writeable_chroot=YES
懶得手動改,可以將上面的patch 文件保存到機器上,然后使用
1 $ cd / 2 $ sudo patch -p0 < [patch文件路徑] 3 這樣就將配置更新了。 4 5 創建登錄用戶 6 #先創建ftp目錄 7 $ sudo mkdir /home/ftpdir 8 #添加用戶 9 $ sudo useradd -d /home/ftpdir -s /bin/bash ftpuser 10 #設置用戶密碼 11 $ sudo passwd ftpuser 12 #設置ftp目錄用戶權限 13 $ sudo chown ftpuser:ftpuser /home/ftpdir 14 15 添加vsftpd 登錄用戶 16 #新建文件/etc/vsftpd.user_list,用於存放允許訪問ftp的用戶: 17 $ sudo touch /etc/vsftpd.user_list 18 $ sudo vim /etc/vsftpd.user_list 19 在/etc/vsftpd.user_list中添加允許登錄ftp 的用戶 20 ftpuser 21 22 添加vsftpd登錄用戶對目錄樹的權限 23 #新建文件/etc/vsftpd.chroot_list,設置可列出、切換目錄的用戶: 24 $ sudo touch /etc/vsftpd.chroot_list 25 $ sudo vim /etc/vsftpd.chroot_list 26 在/etc/vsftpd.chroot_list 設置可列出、切換目錄的用戶 27 ftpuser
重啟 vsftpd 服務
1 $ sudo service vsftpd restart
驗證ftp服務
————————————————
版權聲明:本文為CSDN博主「迦藍葉」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/soslinken/article/details/79304076