在阿里云主机上基于CentOS用vsftpd搭建FTP服务器
最近需要在一臺阿里云的云服務(wù)器上搭建FTP服務(wù)器,在這篇博文中分享一下我們根據(jù)實際需求進行的一些配置。
ftp軟件用的是vsftpd。
vsftpd是一款在Linux發(fā)行版中最受推崇的FTP服務(wù)器程序。特點是小巧輕快,安全易用。
vsftpd 的名字代表”very secure FTP daemon”,安全是它的開發(fā)者 Chris Evans 考慮的首要問題之一。在這個 FTP 服務(wù)器設(shè)計開發(fā)的最開始的時候,高安全性就是一個目標。
準備工作
安裝vsftpd
yum install vsftpd設(shè)置開機啟動vsftpd ftp服務(wù)
chkconfig vsftpd on打開vsftpd配置文件
vi /etc/vsftpd/vsftpd.conf需求及配置
1. 不允許匿名訪問
anonymous_enable=NO2. 使用本地帳戶進行FTP用戶登錄驗證
2.1 允許使用本地帳戶進行FTP用戶登錄驗證
local_enable=YES2.2 創(chuàng)建用于FTP登錄的本地帳戶
增加用戶ftpuser,主目錄為/home/ftp,禁止登錄SSH權(quán)限。
useradd -d /home/ftp -g ftp -s /sbin/nologin ftpuser -p password該命令參考自:CentOS 6.2 ftp 配置。
useradd命令參考文檔:Linux的useradd
2.3 只允許剛創(chuàng)建的ftpuser登錄FTP
vi /etc/vsftpd/vsftpd.conf
userlist_enable=YES userlist_deny=NOvi /etc/vsftpd/user_list
注釋所有帳戶,添加ftpuser
# vsftpd userlist # If userlist_deny=NO, only allow users in this file # If userlist_deny=YES (default), never allow users in this file, and # do not even prompt for a password. # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers # for users that are denied. #root #bin #daemon #adm #lp #sync #shutdown #halt #mail #news #uucp #operator #games #nobody ftpuser配置到這里,就可以遠程用FTP客戶端登錄并上傳文件,文件會保存在ftpuser的主目錄,也就是/home/ftp。
3. 不允許FTP下載
vi /etc/vsftpd/vsftpd.conf
download_enable=NO4. 只允許指定的IP才能連接
4.1 安裝tcp_wrappers
yum -y install tcp_wrappers4.2 檢查tcp_wrappers是否被設(shè)置為YES
vi /etc/vsftpd/vsftpd.conf
tcp_wrappers=YES4.3 添回允許的IP
vi /etc/hosts.allow
vsftpd:允許的IP地址4.4 拒絕所有其他的IP
vi /etc/hosts.deny
vsftpd:ALL轉(zhuǎn)載于:https://www.cnblogs.com/microtiger/p/6228175.html
總結(jié)
以上是生活随笔為你收集整理的在阿里云主机上基于CentOS用vsftpd搭建FTP服务器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: BASH命令和SHELL脚本学习
- 下一篇: 基于libvlc和wxWidgets的简