Golfreeze.packetlove.com: Life style of Golfreeze Canon400D Family kammtan.com Jazz Freebsd Unix Linux System Admin guitar Music
All about unix linux freebsd and FAQ for Packetlove.com Web hosting , Mail hosting , VoIP + IP PBX server => all application on unix knowledges by golfreeze => Topic started by: golfreeze on พฤศจิกายน 08, 2011, 04:59:48 pm
-
ติดตั้งโปรแกรม proftpd ป้องกันการ list folder user อื่น , Use this to jail all users in their homes
บางทีเราต้องการซ่อนไม่ให้ user ที่ login ftp server เข้ามาทำการไป view ดูไฟล์นอกจาก folder ของตัวเองนะครับ
ทำได้โดยเพิ่ม config ที่เป็น
########
DefaultRoot ~
IdentLookups off
ServerIdent on "FTP Server ready."
########
ลงไปในไฟล์ "/etc/proftpd/proftpd.conf"
แล้วทำการ restart service proftpd ครับ
#/etc/init.d/proftpd restart
แค่นี้ก็ป้องกันการ view ดูได้แล้วครับผม
ถ้าต้องการศึกษา security ของ proftpd เพิ่มเติมดูได้จาก : http://proftpd.org/localsite/Userguide/linked/userguide.html
:)
-
ถ้าเป็น vsftpd ก็ให้เปิด config บันทัด
# vi /etc/vsftpd/vsftpd.conf
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
แล้วก็ทำการเพิ่ม user ที่ต้องการห้ามออกไป folder อื่นนอกจาก ของตนเองลงไป
#vi /etc/vsftpd/chroot_list
test1
แล้วทำการ restart service vsftpd
#/etc/init.d/vsftpd restart
จากนั้นเทส FTP client โดยใช้ user = test1 ก็จะไม่สามารถออกไป folder อื่นนอกจาก ของตนเองลงไป
ครับผม
-
ดีมากเลยครับ
-
ในกรณีถ้า ตั้งคอนฟิค chroot ไว้แล้วแต่ว่า มี folder อื่นที่ต้องการให้ user =test1 เข้าไปได้ แต่ว่าอยู่ด้านนอกของ folder home test1
ก็สามารถปรับแก้ง่ายๆ ได้ตามนี้ครับผม
home dir test1 = /home/test1
folder ที่อยากให้เข้าได้อีก = /var/www/www_dev
mkdir /home/test1/www_dev
mount --bind /var/www/dev/ /home/test1/www_dev
เท่านี้ก็เรียบร้อยครับผม
-
สรุปเรื่อง FTP Transfer mode ระหว่าง Active mode กับ Passive mode ครับ
ต่างกันแค่เรื่อง Port FTP Data ที่ใช้ส่งครับ เพื่อให้ใช้งานเหมาะสมกับ Firewall policy ที่อนุญาตในแต่ละ site งาน
The following chart should help admins remember how each FTP mode works:
Active FTP :
command : client >1023 -> server 21
data : client >1023 <- server 20
Passive FTP :
command : client >1023 -> server 21
data : client >1024 -> server >1023
A quick summary of the pros and cons of active vs. passive FTP is also in order:
Active FTP is beneficial to the FTP server admin, but detrimental to the client side admin. The FTP server attempts to make connections to random high ports on the client, which would almost certainly be blocked by a firewall on the client side. Passive FTP is beneficial to the client, but detrimental to the FTP server admin. The client will make both connections to the server, but one of them will be to a random high port, which would almost certainly be blocked by a firewall on the server side.
Luckily, there is somewhat of a compromise. Since admins running FTP servers will need to make their servers accessible to the greatest number of clients, they will almost certainly need to support passive FTP. The exposure of high level ports on the server can be minimized by specifying a limited port range for the FTP server to use. Thus, everything except for this range of ports can be firewalled on the server side. While this doesn't eliminate all risk to the server, it decreases it tremendously. See Appendix 1 for more information.
-
==You will need to enable PassivePorst in your proftd.conf -
PassivePorts 35000 40000
Enable the ip_conntrack_ftp module
#modprobe ip_conntrack_ftp
/etc/init.d/proftpd restart