阿里雲基於CentOS用vsftpd搭建FTP伺服器_Linux

來源:互聯網
上載者:User

最近需要在一台阿里雲的雲端服務器上搭建FTP伺服器,在這篇博文中分享一下我們根據實際需求進行的一些配置。

ftp軟體用的是vsftpd。

vsftpd是一款在Linux發行版中最受推崇的FTP伺服器程式。特點是小巧輕快,安全易用。

vsftpd 的名字代表”very secure FTP daemon”,安全是它的開發人員 Chris Evans 考慮的首要問題之一。在這個 FTP 伺服器設計開發的最開始的時候,高安全性就是一個目標。

準備工作

安裝vsftpd

yum install vsftpd

設定開機啟動vsftpd ftp服務

chkconfig vsftpd on

開啟vsftpd設定檔

vi /etc/vsftpd/vsftpd.conf

需求及配置

1. 不允許匿名訪問

anonymous_enable=NO

2. 使用本地帳戶進行FTP使用者登入驗證

2.1 允許使用本地帳戶進行FTP使用者登入驗證

local_enable=YES

2.2 建立用於FTP登入的本地帳戶

增加使用者ftpuser,主目錄為/home/ftp,禁止登入SSH許可權。

useradd -d /home/ftp -g ftp -s /sbin/nologin ftpuser -p password

該命令參考自:CentOS 6.2 ftp 配置。

useradd命令參考文檔:Linux的useradd

2.3 只允許剛建立的ftpuser登入FTP

vi /etc/vsftpd/vsftpd.conf

userlist_enable=YES
userlist_deny=NO

vi /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=NO

4. 只允許指定的IP才能串連

4.1 安裝tcp_wrappers

yum -y install tcp_wrappers

4.2 檢查tcp_wrappers是否被設定為YES

vi /etc/vsftpd/vsftpd.conf

tcp_wrappers=YES

4.3 添回允許的IP

vi /etc/hosts.allow

vsftpd:允許的IP地址

4.4 拒絕所有其他的IP

vi /etc/hosts.deny

vsftpd:ALL

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援雲棲社區。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.