본문 바로가기

Linux Server 구축/2-1. FTP Server

FTP Server - vsftp


FTP server - vsftp

- vsftp
Very Secure FTP의 약자이다.
안정적이고 빠르며 보안이 강화된 FTP로 Redhat, Suse, Open-BSD등에서 기본으로 채택하는 FTP서버이다.

-------------------------------------------------------------------

vsftp 공식 홈페이지  : http://vsftpd.beasts.org/
vsftp 관련 파일 다운로드 : ftp://vsftpd.beasts.org/users/cevans/

-------------------------------------------------------------------

1. 설치 확인

[root@localhost ~]# rpm -qa | grep vsftp
vsftpd-2.0.5-12.el5

[root@localhost ~]# rpm -qi vsftpd
Name        : vsftpd                       Relocations: (not relocatable)
Version     : 2.0.5                             Vendor: CentOS
Release     : 12.el5                        Build Date:
Install Date:       Build Host: builder16.centos.org
Group       : System Environment/Daemons    Source RPM: vsftpd-2.0.5-12.el5.src.rpm
Size        : 289673                           License: GPL
Signature   : DSA/SHA1, 2008년 06월 15일 (일) 오전 08시 41분 45초, Key ID a8a447dce8562897
URL         : http://vsftpd.beasts.org/
Summary     : vsftpd - 매우 안전한 Ftp 데몬
Description :
vsftpd는 매우 안전한 FPT 데몬입니다. 이것은 완전히 처음부터 작성되었습니다.
 
[root@localhost ~]# system-config-packages

- 패키지 관리자를 통해서 설치 할수도 있다.
패키지 관리자 -> 서버 -> FTP 서버 를 선택하면 vsftp가 설치가 된다.
(옵션사항에는 없지만 기본적으로 설치된다.)

-------------------------------------------------------------------

2. 설치 파일 확인

[root@localhost ~]# rpm -ql vsftpd
/etc/logrotate.d/vsftpd.log
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-2.0.5

- 중략

/usr/share/doc/vsftpd-2.0.5/vsftpd.xinetd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz
/var/ftp
/var/ftp/pub

-------------------------------------------------------------------

3. vsftp 설치 폴더 확인 및 환경 설정 파일 확인

[root@localhost vsftpd]# pwd
/etc/vsftpd
[root@localhost vsftpd]# ls
ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh

-------------------------------------------------------------------

4. 환경설정 파일 설정 - vsftpd.conf

- 자세한 정보는 [ FTP Server - vsftpd.conf ] 를 참고 한다.


4-1. ftp 접속 및 dirmessage_enable=yes 옵션 확인

[root@localhost vsftpd]# vi vsftpd.conf

33 # Activate directory messages - messages given to remote users when they
34 # go into a certain directory.
35 dirmessage_enable=YES

- 특정 폴더에 접속시 .message 파일의 메시지를 보여줄 것인지를 지정하는 설정이다.

-------------------------------------------------------------------

예제)
[root@localhost ~]# ftp 10.10.0.101 - 현재 10.10.0.101 이 FTP 서버로 운영중이다.
Connected to 10.10.0.101.
220 (vsFTPd 2.0.4)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (10.10.0.101:root): anonymous           - 익명사용자로 접속한다.
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls   
227 Entering Passive Mode (10,10,0,101,90,47)
150 Here comes the directory listing.
drwxr-xr-x   19 0        0            4096 Dec 18 00:44 pub
226 Directory send OK.
ftp> cd pub
250-skydriver ftp server !!!       - pub폴더에 설정해 놓은 .message의 내용을 pub에 접근할시 나타난다.
250 D
ftp> help  - ftp에서 사용하는 관련 명령어를 확인할 수 있다.
Commands may be abbreviated.  Commands are:

!               cr              mdir            proxy           send
$               delete          mget            sendport        site
account         debug           mkdir           put             size
append          dir             mls             pwd             status
ascii           disconnect      mode            quit            struct
bell            form            modtime         quote           system
binary          get             mput            recv            sunique
bye             glob            newer           reget           tenex
case            hash            nmap            rstatus         trace
ccc             help            nlist           rhelp           type
cd              idle            ntrans          rename          user
cdup            image           open            reset           umask
chmod           lcd             passive         restart         verbose
clear           ls              private         rmdir           ?
close           macdef          prompt          runique
cprotect        mdelete         protect         safe
ftp> quit   - ftp 에서 나가는 명령어이다.
221 Goodbye.
[root@localhost ~]#

-------------------------------------------------------------------

4-2. ftp 접속 및 ftpd_banner 옵션 확인

[root@localhost vsftpd]# vi vsftpd.conf

82 # You may fully customise the login banner string:
83 #ftpd_banner=Welcome to blah FTP service.

- ftp 서버 접속시 안내메세지를 출력한다.

-------------------------------------------------------------------

예제)
[root@localhost ~]# ftp 10.10.0.101

Connected to 10.10.0.101.
220 Welcome to skydriver FTP service.    - ftp 서버 접속시에 나타난다.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (10.10.0.101:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

-------------------------------------------------------------------

4-3. ftp 접속 및 chroot 옵션 확인

[root@localhost vsftpd]# vi vsftpd.conf

91 # You may specify an explicit list of local users to chroot() to their home
92 # directory. If chroot_local_user is YES, then this list becomes a list of
93 # users to NOT chroot().
94 #chroot_list_enable=YES
95 # (default follows)
96 #chroot_list_file=/etc/vsftpd/chroot_list

97 #chroot_local_user=YES    - 전체 사용자들에게 chroot 기능을 설정한다. 이 설정은 따로 입력해야 한다.

- chroot list에 등록한 사용자만 chroot를 사용하거나 전체 사용자들에게 chroot를 사용하게 할수 있다. .

-------------------------------------------------------------------

예제)
chroot 설정을 안 했을 경우
[root@localhost ~]# ftp 10.10.33.100
Connected to 10.10.33.100.
220 Welcome to skydriver FTP service.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (10.10.33.100:root): test2
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (10,10,33,100,220,7)
150 Here comes the directory listing.
drwxrwxr-x    2 501      501          4096 Dec 12 06:59 public_html   - test2의 홈디렉토리에 있는 파일 리스트이다.
226 Directory send OK.
ftp> pwd
257 "/home/test2"
ftp> cd /root
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (10,10,33,100,239,119)
150 Here comes the directory listing.
-rw-r--r--    1 0        0        26361791 Dec 12 01:13 640-8023[1].22.alz
-rw-r--r--    1 0        0         4314759 Dec 02 04:53 CCNA4_Practice_Labs.zip

- 중략

-rw-r--r--    1 0        0          318464 Nov 19 01:30 xinetd-2.3.14-10.el5.src.rpm
-rw-r--r--    1 0        0          387187 Dec 15 05:32 zb4pl8.tgz
226 Directory send OK.
ftp>

- 이렇게 chroot 기능을 사용해 주지 않으면 일반 사용자가 root의 파일 리스트틀 확인 할수 있다.
실제적으로 퍼미션(권한)에 의해 추가/생성/삭제 등은 할수 없지만 리스트를 확인할 수 있기 때문에 보안상의 문제가 생길 수 있다.

-------------------------------------------------------------------

chroot 의 chroot_list에 일반 사용자들을 추가해 주면 ftp접속시 자신의 홈디렉토리가 '/' 디렉토리가 된다.

예제) chroot 설정을 했을 경우
[root@localhost ~]# ftp 10.10.33.100
Connected to 10.10.33.100.
220 Welcome to skydriver FTP service.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (10.10.33.100:root): test2
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/"       - 자신의 홈디렉토리 (/home/test2)가 '/' 디렉토리가 되었다.
ftp>
ftp> ls -R   - ls -R을 하면 하위 경로와 그 안에 있는 모든 파일들도 나열한다.
227 Entering Passive Mode (10,10,33,100,49,45)
150 Here comes the directory listing.
drwxrwxr-x    2 501      501          4096 Dec 18 01:26 public_html
226 Directory send OK.
ftp>


-------------------------------------------------------------------

4-4. ftp 접속 & userlist_enable 옵션 확인- 접속 제한

[root@localhost vsftpd]# vi vsftpd.conf

114 pam_service_name=vsftpd   - pam 사용자 인증 설정
115 userlist_enable=YES  - user_list 사용을 허가하겠다는 설정
116 tcp_wrappers=YES  - tcp_wrappers 기능을 사용하겠다는 설정

- 각각의 설정을 통해 ftp의 접속을 제한하는 방법을 설정한다.

-------------------------------------------------------------------

4-4-1. user_list와 관련된 파일 설정 확인

[root@localhost vsftpd]# pwd
/etc/vsftpd
[root@localhost vsftpd]# ls
ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh
[root@localhost vsftpd]# cat user_list

1 # vsftpd userlist
2 # If userlist_deny=NO, only allow users in this file - 이 파일에 있는 사용자만 ftp접속을 허용하겠다는 설정이다.
3 # If userlist_deny=YES (default), never allow users in this file, and - 이파일에 있는 사용자만 ftp접속을 거부하겠다는 설정이다. (default 설정)
4 # do not even prompt for a password.
5 # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
6 # for users that are denied.  - root ~ nobody 사이의 사용자들은 ftp접속이 금지된다.
7 root
8 bin
9 daemon
10 adm
11 lp
12 sync
13 shutdown
14 halt
15 mail
16 news
17 uucp
18 operator
19 games
20 nobody

-------------------------------------------------------------------

4-4-2. pam_service와 관련된 파일 설정 확인

[root@localhost vsftpd]# pwd
/etc/vsftpd
[root@localhost vsftpd]# ls
ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh
[root@localhost vsftpd]# cat ftpusers 

# Users that are not allowed to login via ftp - root ~ nobody 사이의 사용자들은 ftp접속이 금지된다.
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

- 현재 userlist와 pam 인증으로 사용자의 접근 제한이 이중으로 되어 있다.
pam 사용자 인증의 경우에는 무조건 접근 금지이지만 userlist는 설정에 따라 접근이 허용/거부 된다.

예를 들어 root 사용자로 ftp 접근이 가능하려면
userlist, ftpusers 두 파일의 설정을 모두 변경해 주어야 한다.

-------------------------------------------------------------------

5. ftp 홈디렉토리

[root@localhost vsftpd]# cd /var/ftp
[root@localhost ftp]# pwd
/var/ftp
[root@localhost ftp]# ll
합계 8
drwxr-xr-x 2 root root 4096  5월 25  2008 pub  - 익명사용자가 접속했을 경우 가장 먼저 나타나는 폴더이다.
[root@localhost ftp]#

-------------------------------------------------------------------

6. 10.10.33.3 에서 ftp 10.10.33.100으로 접속

[root@localhost ~]# ftp 10.10.33.100
Connected to 10.10.33.100.
220 Welcome to skydriver FTP service.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (10.10.33.100:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (10,10,33,100,76,182)
150 Here comes the directory listing.
drwxr-xr-x    3 0        0            4096 Dec 18 01:32 pub
226 Directory send OK.
ftp> cd pub
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (10,10,33,100,224,207)
150 Here comes the directory listing.
drwxr-xr-x    2 0        0            4096 Dec 18 01:32 100
-rw-r--r--    1 0        0               8 Dec 18 01:32 100.txt
226 Directory send OK.
ftp> get 100.txt     -  ftp내에서 파일을 다운로드 하는 명령어로 'get'을 사용한다.         
local: 100.txt remote: 100.txt
227 Entering Passive Mode (10,10,33,100,127,2)
150 Opening BINARY mode data connection for 100.txt (8 bytes).
226 File send OK.
8 bytes received in 7.2e-05 seconds (1.1e+02 Kbytes/s)
ftp> lcd     -  ftp내에서 파일을 다운로드한 경로를 확인하는 명령어로 'lcd'를 사용한다.
Local directory now /root
ftp>

-------------------------------------------------------------------

6-1. 10.10.33.100에서 다운 받은 파일 확인

[root@localhost ~]# pwd
/root
[root@localhost ~]# ll
합계 140
-rw-r--r-- 1 root root     8 12월 18 10:34 100.txt   - 10.10.33.100 에서 다운 받은 파일
drwxr-xr-x 5 root root  4096 12월 18 10:32 Desktop
-rw------- 1 root root  1426 11월 26 21:52 anaconda-ks.cfg
drwxr-xr-x 2 root root  4096 12월  9 18:22 dwhelper
-rw-r--r-- 1 root root 35803 11월 26 21:52 install.log
-rw-r--r-- 1 root root  5945 11월 26 21:51 install.log.syslog
-rw-r--r-- 1 root root 65085 12월 10 14:49 tcpdump.txt
[root@localhost ~]#

-------------------------------------------------------------------

7. ftp 10.10.33.100에 파일 업로드

[root@localhost ~]# ftp 10.10.33.100
Connected to 10.10.33.100.
220 Welcome to skydriver FTP service.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (10.10.33.100:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/"
ftp> ls
227 Entering Passive Mode (10,10,33,100,214,176)
150 Here comes the directory listing.
drwxr-xr-x    3 0        0            4096 Dec 18 01:32 pub
226 Directory send OK.
ftp> cd pub
250 Directory successfully changed.
ftp> put 10.10.33.3.txt     -  ftp내에서 파일을 업로드 하는 명령어로 'put'을 사용한다.
local: 10.10.33.3.txt remote: 10.10.33.3.txt
227 Entering Passive Mode (10,10,33,100,89,205)
553 Could not create file.
ftp> ls
227 Entering Passive Mode (10,10,33,100,139,110)
150 Here comes the directory listing.
-rw-------    1 14       50              8 Dec 18 01:41 10.10.33.3.txt  - 10.10.33.100으로 업로드한 파일
drwxr-xr-x    2 0        0            4096 Dec 18 01:32 100
-rw-r--r--    1 0        0               8 Dec 18 01:32 100.txt
226 Directory send OK.
ftp> mkdir 10.10.33.3
257 "/pub/10.10.33.3" created
ftp> ls
227 Entering Passive Mode (10,10,33,100,86,55)
150 Here comes the directory listing.
-rw-------    1 14       50              8 Dec 18 01:41 10.10.33.3.txt
drwx------    2 14       50           4096 Dec 18 01:41 10.10.33.3
drwxr-xr-x    2 0        0            4096 Dec 18 01:32 100
-rw-r--r--    1 0        0               8 Dec 18 01:32 100.txt
226 Directory send OK.
ftp> cd 10.10.33.3  - 10.10.33.3이 생성한 폴더로 이동한다.
250 Directory successfully changed.
ftp> put 10.10.33.3.txt   - 10.10.33.3의 폴더에 파일을 업로드 한다.
local: 10.10.33.3.txt remote: 10.10.33.3.txt
227 Entering Passive Mode (10,10,33,100,227,165)
150 Ok to send data.
226 File receive OK.
11 bytes sent in 5.2e-05 seconds (2.1e+02 Kbytes/s)
ftp> pwd
257 "/pub/10.10.33.3"
ftp> ls   - 현재 폴더의 리스트를 확인할수 없는데 이것은 퍼미션과 관련된 사항으로 현재 폴더의 other에 대한 권한이 없기 때문이다.
227 Entering Passive Mode (10,10,33,100,30,172)
150 Here comes the directory listing.
226 Transfer done (but failed to open directory).
ftp>

-----------------------------

- 참고
/etc/vsftpd.conf 파일을 수정한 후에는 항상 vsftpd 서비스를 재시작 해준다.

# service vsftpd start

'Linux Server 구축 > 2-1. FTP Server' 카테고리의 다른 글

filezilla - FTP Client Program  (0) 2008.12.18
FTP Server - proftpd.conf  (0) 2008.12.18
FTP Server - proftpd  (0) 2008.12.18
FTP Server - vsftp - vsftpd.conf  (0) 2008.12.18