6/04/2016

UBUNTU : ติดตั้งบริการ FTP

1.ติดตั้ง vsftpd
[code=bash]sudo apt-get install vsftpd[/code]

2.ปรับแต่ง config
[code=bash]sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.original #สำรองไว้ก่อน[/code]
ปรับได้ 3 แบบ
[code=bash]# 1. All users are jailed by default:  คือ User ทั้งหมดเข้าไม่ได้ เป็นค่า Default
chroot_local_user=YES
chroot_list_enable=NO

# 2. Just some users are jailed:  คือ Connect เข้าได้เฉพาะ User ที่ไม่ได้อยู่ใน File vsftpd.chroot_list และ List ดู Folder ได้
chroot_local_user=NO
chroot_list_enable=YES
# Create the file /etc/vsftpd.chroot_list with a list of the jailed users.

# 3. Just some users are "free": คือ เข้าดูได้ทุก User ที่มีชื่ออยู่ใน File vsftpd.chroot_list  และ List Folder ได้
chroot_local_user=YES
chroot_list_enable=YES
# Create the file /etc/vsftpd.chroot_list with a list of the "free" users[/code]

3.จัดการ User โดยเลือกแบบที่ 3  เป็นส่วนที่ใช้สร้าง Folder ที่ต้องการให้ FTP เข้า มา จะเป็นที่ FTP เข้ามาจะเห็นที่ Folder นี้เลย
สร้างไว้ที่อื่นก็ได้
[code=bash]sudo useradd -d /home/user1 user1
sudo mkdir /home/user1
sudo chown user1 /home/user1
sudo passwd user1 #ตั้งรหัสผ่าน[/code]
กรณีต้องการให้ ftp เข้าไปแก้ www
[code=bash]gpasswd -a user1 www-data[/code]
เพิ่ม user1 เข้าไปในไฟล์ [color=#0000FF]/etc/vsftpd.chroot_list[/color] แล้ว restart service
[code=bash]sudo /etc/init.d/vsftpd restart[/code]
หรือใช้คำสั่ง
[code=text]service vsftpd restart[/code]

ถ้าต้องการให้แก้ไขได้หรือไม่ได้ให้แก้
write_enable=YES   คือ สิทธ์ของ User ตามข้อ 3 แก้ไข ลบได้
write_enable=NO  คือ อ่านเข้าไปดูได้อย่างเดียวแก้ไขไม่ได้

For Ubuntu 12.04 Use This Method.
- Back up the config file before making a change;
[code=text]sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.back[/code]

- and then edit vsftpd.conf (with vi or nano)
[code=text]nano /etc/vsftpd.conf[/code]

- Then make the following change
[code=text]    pam_service_name=ftp[/code]

- Restart Service
[code=text]sudo service vsftpd restart[/code]

[url]http://askubuntu.com/questions/413677/vsftpd-530-login-incorrect[/url]

No comments:

Post a Comment