8/1/12

CẤU HÌNH FTP SERVER


1.1.1.     CẤU HÌNH FTP SERVER

Mô hình và yêu cầu hệ thống

Cấu hình cho phép người dùng anonymous và local user upload dữ liệu lên FTP Server theo mô hình sau đây:

Hướng dẫn cấu hình

a)     Tạo người dùng cục bộ
b)     Khai báo tên miền ftp.serverlinux.vn trong DNS server
c)     Cài đặt vsftpd
d)     Cấu hình tập tin /etc/vsftpd/vsftpd.conf
e)     Khởi động dịch vụ FTP
f)      Kiểm tra hoạt động
1)     Kiểm tra tiến trình vsftpd
2)     Login bằng người dùng anonymous trên windows
3)     Upload tài liệu
4)     Login bằng tài khoản hv1 trên windows
5)     Upload tài liệu
g)     Ftp client từ Linux
h)     ftp client từ Windows

Các bước thực hiện

a)   Tạo người dùng cục bộ
[root@localhost ~]# useradd hv1     #tạo người dùng hv1
useradd: user hv1 exists

[root@localhost ~]# passwd hv1      #đặt mật khẩu tạo người dùng hv1
Changing password for user hv1.
New UNIX password:            #Nhập mật khẩu vào
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:     #xác thực lại mật khẩu
passwd: all authentication tokens updated successfully.

b)  Cấu hình zone thuận serverlinux.vn
$TTL  86400
@           IN    SOA   dns1.serverlinux.vn.    root.serverlinux.vn.(
                        2011022700 ; Serial
                        28800; Refresh
                        14400; Retry
                        3600000; Expire
                        86400 ); Minimum
IN    NS    dns1.serverlinux.vn.
      IN    MX    1     dns1.serverlinux.vn.
dns1  IN    A     192.168.1.17
www   IN    CNAME dns1.serverlinux.vn.
mail  IN    CNAME dns1.serverlinux.vn.
ftp   IN    CNAME 192.168.1.28
proxy IN    CNAME dns1.serverlinux.vn.
c)   Khởi động dns server
[root@localhost ~]# /etc/init.d/named restart
Stopping named:               [OK]
Starting named:               [OK]

[root@localhost ~]# hostftp.serverlinux.vn
[root@localhost ~]# host ftp.serverlinux.vn
ftp.serverlinux.vn is an alias for ns1.serverlinux.vn.
dns1.serverlinux.vn has address 192.168.1.17
d)  Cài đặt vsftpd
[root@linux ~]#yum -y install vsftpd
e)   Cấu hình tập tin /etc/vsftpd/vsftpd.conf
[root@linux ~]#vi /etc/vsftpd/vsftpd.conf
# line 12: no anonymous
anonymous_enable=NO     #Không cho phép người dùng anonymous login vào
# line 81,82: uncomment (permit ascii mode transfer)
ascii_upload_enable=YES
ascii_download_enable=YES
# line 96: uncomment ( enable chroot list )
chroot_list_enable=YES
chroot_local_user=YES
# line 99: uncomment ( enable chroot list file )
chroot_list_file=/etc/vsftpd/chroot_list
# line 105: uncomment
ls_recurse_enable=YES
# add at the bottom
# specify root directory ( if don't specify, users' home directory become FTP home directory )
local_root=public_html
# use localtime
use_localtime=YES       #sử dụng thời gian hệ thống

[root@linux ~]# vi /etc/vsftpd/chroot_list
# add users you allow to move over their home directory
hv1
f)    Tắt firewall: FTP server khi chạy mở port (20,21) nên ta phải mở 2 port này bằng cách tắt firewall
[root@linux ~]# /etc/init.d/iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
g)   Khởi động dịch vụ FTP
[root@linux ~]# /etc/rc.d/init.d/vsftpd start
Starting vsftpd for vsftpd:         [OK]
[root@linux ~]# chkconfig vsftpd on
h)  Ftp client từ Linux
[root@linux vsftpd]# ftp 192.168.1.28
Connected to 192.168.1.28.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (192.168.1.28:root): hv1
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
Kiểm tra
ftp> ls
227 Entering Passive Mode (192,168,1,28,41,97)
150 Here comes the directory listing.
226 Directory send OK.
ftp>
i)    Ftp client  FileZilla từ Windows
Hoặc gõ lệnh trong Run: ftp://192.168.1.28

Bài đăng phổ biến