woff 發表於 2020-9-8 12:30:11

在 CentOS 7.x 上使用 vsftpd FTP Server chroot

1. 安裝 vsftpd FTP Server
# yum install -y vsftpd

2. 修改設定檔 /etc/vsftpd/vsftpd.conf
# grep -v ^# /etc/vsftpd/vsftpd.conf
anonymous_enable=No
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/xferlog
idle_session_timeout=600
data_connection_timeout=120
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
allow_writeable_chroot=YES
listen=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

pasv_enable=YES
pasv_min_port=5000
pasv_max_port=6000
use_localtime=YES
3. 讓 root 可以登入
sed -i 's/root/#root/' /etc/vsftpd/ftpusers
sed -i 's/root/#root/' /etc/vsftpd/user_list

4. 限制使用者不能切換到其它目錄,root 可以
echo root > /etc/vsftpd/chroot_list

5. SELinux 在 vsftpd FTP Server 上的設定
setsebool -P ftp_home_diron
setsebool -P allow_ftpd_full_accesson

6. 設定開機時啟動
systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

7. 啟動 vsftpd FTP Serversystemctl start vsftpd

8. 檢查 FTP Server 是否有正常啟動
netstat -ant | grep :21
tcp      0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN

關於 chroot 使用者的另一種做法
1. 修改 /etc/vsftpd/vsftpd.conf 設定檔
# grep 'chroot' /etc/vsftpd/vsftpd.conf | grep -v '^#'
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
allow_writeable_chroot=YES

2. 建立要 chroot 的使用者
awk -F: '{if ($3>999) print $1}' /etc/passwd | grep -v nfsnobody > /etc/vsftpd/chroot_list

awk -F: '{if ($3>999&&$3<60000) print $1}' /etc/passwd > /etc/vsftpd/chroot_list

文章出處:網頁設計,網站架設 ,網路行銷,網頁優化,SEO - NetYea 網頁設計

參考文章

頁: [1]
查看完整版本: 在 CentOS 7.x 上使用 vsftpd FTP Server chroot