Triển khai dịch vụ FTP trên Linux​

0
1306

FTP – FILE TRANSFER PROTOCOL

Chuẩn bị: Nhóm 2PC

PC1: (FTP Server) sử dụng HDH Linux
PC2: (FTP Client) sử dụng HDH Windows 2003

PC1
– Cài đặt

#mount /dev/cdrom /media
#rpm -ivh /media/CentOS/vsftpd-2.0.5-10.el5.i386.rpm

– Cấu hình
#vi /etc/vsftpd/vsftpd.conf

     12 anonymous_enable=YES
15 local_enable=YES                                //cho phép sử dụng local user truy cập
18 write_enable=YES                                //cho phép upload
27 #anon_upload_enable=YES                 //cho anonymyous upload hay không
31 #anon_mkdir_write_enable=YES
38 xferlog_enable=YES                                        //enable log
51 xferlog_file=/var/log/vsftpd.log                         //đường dẫn log file

83 #ftpd_banner=Welcome to ispace.                  //banner
115 userlist_enable=YES                            //danh sách user không truy cập ftp

– Tạo 2 user nv1/123; nv2/123
– Start service

#service vsftpd start
#chkconfig vsftpd on

PC2
– Truy cập FTP => ok
image002
– Tạo dữ liệu lên FTP => không tạo được
PC1
– Thư mục mặc định: /var/ftp/pub
– Copy dữ liệu vào thư mục trên
PC2
– Truy cập FTP => đã có dữ liệu
– Truy cập FTP bằng user nv1/123 và tạo dữ liệu => ok
image004
PC1
– Kiểm tra lại dữ liệu của nv1
image006
PC2
– Truy cập FTP bằng user nv2/123 và tạo dữ liệu => ok; nhưng không thấy dữ liệu của nv1/123
– Truy cập FTP bằng giao diện cmd
image008
Cấu hình FTP server
1. Thay đổi thư mục root của anonymous
– Tạo cây thư mục

image009

– Cấu hình
#vi /etc/vsftpd/vsftpd.conf                  //thêm vào cuối file 1 dòng
image011
image013
– Restart service

#service vsftpd restart

PC2
– Truy cập FTP => ok
image015
2. Cho phép anonymous upload dữ liệu
– Cấu hình

#vi /etc/vsftpd/vsftpd.conf

image020
Và thêm 1 dòng cuối file
image022
– Restart service

#service vsftpd restart

– Quyền truy cập
#chmod 777 /dataftp/upload
PC2
– Truy cập FTP bằng user anonymous và upload dữ liệu => ok
image024
3. Cấm anonymous truy cập FTP
– Cấu hình

#vi /etc/vsftpd/vsftpd.conf
image026

– Restart service

#service vsftpd restart

PC2
– Truy cập FTP bằng user anonymous
image028
3. Cấm nv1 truy cập FTP
PC1
– Cấu hình

# vi /etc/vsftpd/user_list  và thêm user cần cấm vào cuối file
image030

– Restart service

#service vsftpd restart

PC2
– Truy cập FTP bằng user nv1
image032
4. Multi FTP Site

PC1

Truy cập ftp://192.168.1.110  => anonymous
Truy cập ftp://192.168.1.210 => local user

– Tạo thêm một địa chỉ IP
#cd /etc/sysconfig/network-scripts
#cp ifcfg-eth0 ifcfg-eth0:0
#vi ifcfg-eth0:0

image036

– Restart service

#service network restart

–  Copy thêm 1 file vsftpd.conf

#cd /etc/vsftpd
#cp vsftpd.conf vsftpd1.conf

– Cấu hình vsftpd.conf

#vi /etc/vsftpd/vsftpd.conf      //sửa dòng 12, thêm dòng 13
image038

– Cấu hình vsftpd1.conf

#vi /etc/vsftpd/vsftpd1.conf    //sửa dòng 12, thêm dòng 13
image040

– Restart service

#service vsftpd restart

PC2
– Truy cập FTP bằng cả 2 địa chỉ IP => ok

This site uses Akismet to reduce spam. Learn how your comment data is processed.