在 Ubuntu 16.04上安裝 vsFTPd

在 Ubuntu 16.04上安裝 vsFTPd

關於 vsFTPd

vsFTPd 表明 Very Secure File Transfer Protocol Daemon (很是安全的文件傳輸協議守護進程)。它是一個用於 Unix 和 Linux 操做系統的開源、輕量、穩定、最安全和最快的 FTP 服務器。
一些流行的FTP站點的Debian,FreeBSD,RED HAT,SUSE,Kernel,KDE,GENOME等,就是基於VSFTPD。
它是大多數Linux和Unix操做系統(例如Red Hat,CentOS,Fedora和Ubuntu)的默認FTP服務器。
它支持IPv6和SSL。所以,您可使用VSFTPD爲您的組織設置安全的FTP服務器。它是根據GPL許可的,徹底免費。html

1.更新軟件倉庫

root@mail:/# apt-get update
root@mail:/# apt-get upgrade

2.安裝vsFTPd

root@mail:/# apt-get install vsftpd

備份下配置文件linux

root@mail:/# cp /etc/vsftpd.conf /etc/vsftpd.conf.backup

3.編輯配置文件

使用 nano 打開 vsftpd.confweb

root@mail:/# nano /etc/vsftpd.conf

使用CTRL+W搜索並修改如下配置項:ubuntu

anonymous_enable=NO
local_enable=YES
write_enable=YES
allow_writeable_chroot=YES
chroot_local_user=YES
file_open_mode=0777
local_umask=022

若是存在則取消註釋,不然添加行。安全

4.配置只容許特定用戶訪問

userlist_deny=NO
userlist_enable=YES
userlist_file=/etc/vsftpd.allowed_users

5.建立文件 vsftpd.allowed_users

sudo touch /etc/vsftpd.allowed_users

該文件包含了能夠訪問的用戶名:bash

m.slavov
yourSECONDuser
yourTHIRDuser

若是你想的話還能夠作一些高級配置:服務器

#Useful to not write over hidden files:
force_dot_files=YES

#Hide the info about the owner (user and group) of the files.
hide_ids=YES

#Maximum number of clients:
max_clients=20

#Connection limit for each IP:
max_per_ip=2

#Chnage listen port from 21 to other
listen_port=999

6.添加ftp用戶而且修改它的家目錄

這點很重要,由於你可以限制這個用戶只能訪問一個目錄。你能夠容許它訪問/var/www下的全部站點或只能訪問其中某一個站點。
例如,若是你想建立用戶ftp並只容許它訪問一個站點,輸入如下命令,而且不要忘了在/etc/vsftpd.allowed_users中添加這個用戶:ide

root@mail:/# adduser ftp
root@mail:/# usermod –home /var/www/YOURFOLDERSITE ftp

或者打開文件/etc/passwd,而後搜索你想改變家目錄的用戶,把/home/ftpuser修改成/var/www操作系統

root@mail:/# nano /etc/passwd
root@mail:/# ftpuser:x:1001:1001:FTP USER,,,:/var/www:/bin/bash

7.重啓vsFTPd

爲了使修改生效,你必須重啓vsFTPd服務。命令行

root@mail:/# systemctl restart vsftpd

如今當用戶經過 ftpzilla 鏈接 ftp,只能看到一個站點。
若是你想看到命令的輸出,用命令/etc/init.d/vsftpd restart
顯示vsFTPd狀態,用命令:systemctl status vsftpd

8.配置權限

若是你想全部用戶都有權限寫入到這個文件夾,你必須設置所有權限777。
若是你只想某個組有權限寫入、其餘用戶只能讀,你就得設置權限爲775.

root@mail:/# chmod 777 -R /var/www/YOURFOLDERSITE
root@mail:/# chown ftp:ftp -R /var/www/YOURFOLDERSITE

9.使用 Xftp 鏈接

新建鏈接,輸入 ip 地址和剛纔新建的 ftp 用戶以及密碼。

這裏我遇到一個問題:

在命令行用ftp命令能夠鏈接到 ftp 服務器,可是用 Xftp 鏈接卻老是提示「沒法顯示遠程文件夾」。

解決:

在「會話屬性」的「選項」窗口,勾掉「使用被動模式」,重試。


參考:
http://linux-sys-adm.com/ubuntu-16.04-lts-how-to-install-and-configure-vsftpd-on-ubuntu/
https://www.ostechnix.com/install-vsftpd-server-ubuntu-16-04-lts/

相關文章
相關標籤/搜索