close

Setup a Simple FTP with vsftpd under Linux

RHEL/CentOS: yum install vsftpd
Ubuntu: apt-get install vsftpd

安裝套件之後,編輯/etc/vsftpd/vsftpd.conf設定檔:
vim /etc/vsftpd/vsftpd.conf
沒有提到的部分,維持預設值
local_enable=YES
write_enable=YES
local_root=/ftp #如果需要限制在home底下各個user的目錄,可以這樣寫: local_root=/home/$USER

但後來發現會FTP軟體連線進去之後,會看到Service整個OS的目錄...
 

研究之後是少了限制User只能在ftp跟目錄的設定
chroot_local_user  # local users will be (by default) placed in a chroot() jail in their home directory after login.

加上chroot_local_user相關的設定,

chroot_local_user=YES #限制使用者在家目錄之內(chroot),指的是這裡的設定local_root
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
userlist_enable=YES
userlist_file=/etc/vsftpd/user_list
userlist_deny=NO
allow_writeable_chroot=YES

編輯"/etc/vsftpd/chroot_list"跟"/etc/vsftpd/user_list"

編輯/etc/vsftpd/chroot_list這個檔案

echo {user} | sudo tee -a /etc/vsftpd/user_list

設定好設定檔案,啟用服務
systemctl enable vsftpd #開機自啟動
systemctl start vsftpd #啟動服務

防火牆設定在網域的NAT,所以這台OS沒有開防火牆,若你的環境有防火牆,記得設定唷

 

Ref: https://linux.die.net/man/5/vsftpd.conf
https://blog.miniasp.com/post/2012/08/13/Secure-vsFTPd-with-chroot-and-multiple-user-access-permission-tips
https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-for-a-user-s-directory-on-ubuntu-20-04
https://www.cnblogs.com/wi100sh/p/4542819.html

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 吾給力 的頭像
    吾給力

    吾給力的部落格

    吾給力 發表在 痞客邦 留言(0) 人氣()