การติดตั้งและการใช้งาน vsftp บน Linux
จาก Research 2549, สารานุกรมฟรี
สารบัญ |
บทคัดย่อ
- ในที่นี้จะกล่าวถึงคำว่า VSFTP มาจากคำที่มีความหมายที่น่าสนใจว่า Very Security FTP นั่นก็คิอ ในการติดตั้งเซิร์ฟเวอร์ FTP ขึ้นมาตามหน่วยงานองค์กรต่างๆ เซิร์ฟเวอร์ FTP ทั่วไปมีจุดอ่อนทางด้านความปลอดภัย เนื่องจากโปรแกรมที่ใช้เป็นเซิร์ฟเวอร์ FTP หลายชนิด ไม่ว่าจะเป็น
- WU-FTP
- ProFTP
- BSD-FTP
ทุก server ที่กล่าวมาล้วนมีช่องโหว่ที่ถูกค้นพบมากมาย ทำให้มีเกิดความเสี่ยงต่อการถูกผู้ไม่ประสงค์ดีโจมตีได้ อย่างไรก็ตามได้มีการพัฒนาโปรแกรมหนึ่งที่ชื่อว่า"VSFTP" แก้ไขปัญหาทางความปลอดภัยสำหรับเซิร์ฟเวอร์ FTP ที่เป็น Linux
ประวัติความเป็นมา/ทฤษฏีพื้นฐานที่เกี่ยวข้อง
- vsftp เป็นเซิร์ฟเวอร์ FTP ที่พัฒนาทางด้านความมั่นคงและปลอดภัย ป้องกันและลดความเสี่ยงของการถูกโจมตีผ่านทางช่องโหว่ของ FTP
- ต่อไปเป็นตัวอย่างของ site ที่มีการ run VSFTP
- Red Hat
- OpenBSD
- SuSE
เพราะฉะนั้น VSFTP จึงเป็นอีกทางเลือกหนึ่งสำหรับผู้ที่ต้องการจะติดตั้งเซิร์ฟเวอร์ FTP และต้องการความปลอดภัยยิ่งขึ้น โดย VSFTP ได้ถูกออกแบบมาเพื่อแก้ไขจุดบกพร่องที่พบในการติดตั้ง wu-ftpd, proftpd, และแม้แต่ bsd-ftpd โดยการไม่ใช้บัญชีชื่อ root ซึ่งมีความเสี่ยง และใช้คุณสมบัติด้านความปลอดภัยที่มีประสิทธิภาพอย่าง chroot
- VSFTP เป็นเดมอน (daemon) ของเซิร์ฟเวอร์ FTP ที่รันบนระบบปฏิบัติการ Linux/UNIX ซึ่งมีคุณสมบัติหลักอยู่ 3 อย่าง ได้แก่
- มีความปลอดภัย
- มีประสิทธิภาพดี
- มีความมั่นคง
- เป็นระบบที่มีขนาดเล็ก มีความสามารถในการจัดการ virtual users
- มีทางเลือกในการทำงานเป็นแบบ stand-alone configuration และแบบผ่านทางเดมอน inetd
- สามารถจำกัดปริมาณการรับส่งข้อมูล (bandwidth) ในการให้บริการในเซิร์ฟเวอร์ที่ต้องการควบคุมการใช้งานได้
- ใช้เทคนิคการพัฒนาโปรแกรมอย่างปลอดภัยเพื่อแก้ปัญหาหน่วยความจำล้น (buffer overflows)
สำหรับตัวอย่างที่เป็นข้อยืนยันว่า vsftp มีความปลอดภัยสูง คือ
- ในเดือนพฤศจิกายน พ.ศ. 2545 ไซต์ ftp.openbsd.org ได้รัน vsftpd ซึ่งเป็นการยืนยันได้ว่า vsftpd มีคุณสมบัติดีเหมาะแก่การใช้เป็นเซิร์ฟเวอร์ FTP คุณสมบัติของ VSFTP
การติดตั้ง vsftp
ขั้นตอนการติดตั้งติดตั้ง
- การติดตั้งในที่นี้เป็นการติดตั้งผ่าน apt-get install ซึ่งเป็นการติดตั้งแบบ online โดยมีข้นตอนการติดตั้งดังนี้
1. ติดตั้งโปรแกรมโดยใช้คำสั่ง apt-get install vsftpd ดังรูป
2.ค่า Default บน ubuntu ของ vsftp จะเปิดใช้งานเฉพาะแบบ Anonymous ถ้าต้องการแก้ไขคอนฟิกของ vsftpd ก็แก้ได้ที่ำไฟล์ /etc/vsftpd.conf ดังรูป
3.ไฟล์คอนฟิก /etc/vsfpd.conf จะเป็นดังรูป ซึ่งถ้าต้องการให้ user ทั่วไปสามารถใช้ ftp เป็นขื่อ user ของตัวเองได้ก็ต้องกำหนดค่า local_enable = YES ดังรูป
4.เมื่อมีการแก้ไขคอนฟิกก็ควรจะ restart การทำงาน ด้วยคำสั่งดังรูป
การตรวจสอบว่าติดตั้ง vsftp แล้วหรือยัง
- ตรวจสอบจาก shell prompt
# rpm –q vsftpd
- ตรวจสอบจาก XWindow
- จากเมนูSystem Settings ไปที่ Add/Remove Applications
- รายการ Server ไปที่ FTP Server
วิธีการ Start vsftp
- การ Start จาก shell prompt
- ภาพตัวอย่างการ start vsftp จาก shell prompt ที่มา
(http://www.itwizard.info/technology/linux/myslide/ftp.pdf)
2.การ Start จาก XWindow โดย
ที่ System Settings ไปที่ ServerSettings ไปที่ Services
- ภาพตัวอย่างการ start vsftp จาก XWindow ที่มา
(http://www.itwizard.info/technology/linux/myslide/ftp.pdf)
3.การ Start จาก shell prompt ด้วยคำสั่ง setup
- ภาพตัวอย่างการ start vsftp จาก shell prompt ด้วยคำสั่ง setup ที่มา
(http://www.itwizard.info/technology/linux/myslide/ftp.pdf)
การปรับแต่งค่าคอนฟิกูเรชัน
ประเภทของล็อกอินในบริการ FTP
ค่าคอนฟิกของ vsftp ที่เป็น default ข้อมูลต่อไปนี้คือข้อมูลในไฟล์ /etc/vsftpd.conf
# Example config file /etc/vsftpd.conf # # The default compiled in settings are very paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # # Allow anonymous FTP? anonymous_enable=YES # # Uncomment this to allow local users to log in. local_enable=YES # # Uncomment this to enable any form of FTP write command. write_enable=YES # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. #anon_upload_enable=YES # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES # # Activate logging of uploads/downloads. xferlog_enable=YES # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # You may override where the log file goes if you like. The default is shown # below. #xferlog_file=/var/log/vsftpd.log # # If you want, you can have your log file in standard ftpd xferlog format xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that turning on ascii_download_enable enables malicious remote parties # to consume your I/O resources, by issuing the command "SIZE /big/file" in # ASCII mode. # These ASCII options are split into upload and download because you may wish # to enable ASCII uploads (to prevent uploaded scripts etc. from breaking), # without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be # on the client anyway.. #ascii_upload_enable=YES #ascii_download_enable=YES # # You may fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd.banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). #chroot_list_enable=YES # (default follows) #chroot_list_file=/etc/vsftpd.chroot_list # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES pam_service_name=vsftpd userlist_enable=YES #enable for standalone mode listen=YES tcp_wrappers=YES
การคอนฟิก vsftp ไฟล์คอนฟิกหลักๆของ vsftp คือ /etc/vsftpd.conf รูปแบบการล็อกอินของ vsftp มีดังนี้
- ล็อกอินด้วยผู้ใช้ที่มีอยู่ในระบบ (Real FTP)
ผู้ใช้บริการจะต้องมีชื่อ บัญชีผู้ใช้อยู่จริงบนเซิร์ฟเวอร์ สามารถเปลี่ยนไดเร็คทอรี่ไปที่อื่นได้
- Real FTP คือ ล็อกอินด้วยผู้ใช้ที่มีอยู่ในระบบ
local_enable= YES
- ล็อกอินด้วยผู้ใช้ที่มีอยู่ในระบบแต่จำกัดขอบเขต (Guest FTP)
คล้ายกับ Real FTP ต่างตรงที่ ไม่สามารถเปลี่ยนไดเร็คทอรีไปไหนได้เกิน ขอบเขตที่เซิร์ฟเวอร์กำหนด การกำหนดไม่ให้ user สามารถเปลี่ยนไดเร็คทอรี่ไปที่อื่นได้
chroot_local_user=YES (ไม่มีค่านี้ใน default)
- การตั้งค่าให้เป็น Guest FTP
- ถ้าต้องการให้ user บางคนสามารถ change directory จาก home directory ของ
ตัวเองไปที่อื่นได้ก็ให้ทำดังนี้
chroot_list_enable=YES ป้อนชื่อ user ที่จะอนุญาตให้ changdirectory ได้ไว้ที่ /etc/vsftpd/chroot_list(ต้องสร้าง
ไฟล์ขึ้นมาใหม่ โดยตำแหน่งและชื่อไฟล์นี้เป็น Default)
- ถ้าเราไม่ต้องการเก็บชื่อ user ที่อนุญาตให้ change directory ได้ไว้ในไฟล์ที่เป็น Default คือ /etc/vsftpd/chroot_list ก็สามารถทำได้คือ :
chroot_list_file=ชื่อไฟล์ เช่น chroot_list_file=/root/admin_ftp_user สร้างไฟล์ดังกล่าวขึ้นมา
- ในกรณีที่ต้องการให้ user บางคนสามารถ change directoryได้และต้องการให้ user ดังกล่าวซึ่งอาจจะเป็น system admin สามารถ upload ไฟล์ไปไว้ที่ตำแหน่งของ anonymous ftp ได้ก็ให้คอนฟิกดังนี้
- ให้เปิดบริการ anonymous ftp โดยให้คอนฟิก anonymous ftp เป็นแบบ defaultคือต้องเปลี่ยนค่าต่าง ๆ ต่อไปนี้กลับไปดังเดิม (ด้วยการเอาเครื่องหมาย # ไว้ข้างหน้า)
•anon_upload_enable=YES •anon_mkdir_write_enable=YES •anon_other_write_enable=YES
- เพิ่ม user ที่เป็น system admim ขึ้นมา และให้เพิ่ม group ใหม่ขึ้นมา โดยให้ user ที่เป็น system admim ให้สังกัดอยู่ใน group ดังกล่าว เช่นอาจจะตั้งชื่อ group ใหม่ว่า sysadmim
- กำหนดสิทธิ์ไดเร็คทอรี่ /var/ftp (หรือ /var/ftp/pub แล้วแต่นโยบาย) ให้สังกัดกลุ่มของ sysadmin และกำหนด permission ในตำแหน่งดังกล่าวให้ group สามารถ write ได้ แต่ other ไม่สามารถ write ได้
- ล็อกอินด้วยผู้ใช้ที่ไม่มีอยู่ในระบบ (Anonymous FTP)
ที่เก็บไฟล์สำหรับ anonymous อยู่ที่ /home/ftp เปิดปิด service ด้วยคำสั่ง /etc/init.d/vsftpd start | stop |restart
- การบริการ FTP แบบที่เปิดเสรีให้คนทั่วโลกมาใช้บริการ คงเป็นไปไม่ได้ที่จะมานั่งสร้างบัญชีผู้ใช้ให้รองรับคนทั่วโลก แบบนี้จึงกำหนดให้ล็อกอิน
โดยใช้ชื่อ anonymous ส่วนรหัสผ่านให้ระบุเป็นรูปแบบของ e-mail address
- Anonymous FTP คือ ล็อกอินด้วยผู้ใช้ที่ไม่มีอยู่ในระบบ
anonymous_enable=YES
- ไฟล์คอนฟิกที่เกี่ยวกับ User (Default) มี 2 ไฟล์คือ
/etc/vsftpd/ftpusers /etc/vsftpd/user_list
สรุป
- สรุป vsftp ย่อมาจาก Very Security FTP ความหมายที่ตรงตัวว่า vsftp มีความปลอดภัยมากกว่า ftp ตัวอื่นๆ โดย vsftp นั้นถูกสร้างขึ้นมาเพื่อแก้ไขปัญหาด้านความปลอดภัย มีความมั่นคง และประสิทธิภาพสูง โดยการเข้ามาแก้ไขข้อบกพร่องที่เกิดขึ้นกับ ftp และอุดช่องโหว่เหล่านั้น โดยตัวอย่างที่เห็นได้ชัดคือการนำ VSFTP มาใช้โดยองค์กรใหญ่ๆ หลายหลากหลายองค์กร รวมถึงการเข้าใช้ในโครงการ Open BSD ที่มีการเน้นทางด้านความปลอดภัย หรือแม้แต่กระทั่ง Red Hat Linux
ทั้งนี้เนื่องมาจากคุณสมบัติของ vsftp ที่มีขนาดเล็ก สามารถรับโหลดที่หนักได้ รวมถึงมีความปลอดภัยและใช้งานได้ง่ายด้วย จึงทำให้ VSFTP เหมาะที่จะนำมาใช้เป็นเซิร์ฟเวอร์ FTP ที่มีปัญหาด้านความปลอดภัยน้อยมาก และถูกเลือกใช้มากในปัจจุบัน
เอกสารอ้างอิง และเว็บลิงค์
- ศูนย์ประสานงานการรักษาความปลอดภัยคอมพิวเตอร์ ประเทศไทย, www.thaicert.nectec.or.th
- http://www.itwizard.info/technology/linux/myslide/ftp.pdf (FTP (File Transfer Protocol))
- http://www.itwizard.info/technology/linux/vsftpd_config_default.html(ค่าคอนฟิกของ vsftp ที่เป็น default)
- http://vsftpd.beasts.org/
- http://www.boonjing.com/wisdomwork/index.php?option=com_content&task=view&id=96&Itemid=127 (VSFTP กับ FTP over SSL )
- http://www.boonjing.com/wisdomwork//VSFTPD.FTP.over.SSL.pdf (ทำไมต้อง VSFTP)
