본문 바로가기
Linux/NetAdmin

[CentOS5.11] vsFTP 서버 실습.

by Luuii 2017. 9. 17.

/etc/vsftpd/vsftpd.conf 파일 설정을 통해 vsftp서버의 기능을 테스트 한다.

 

> ( 관리 설정 ) : 배너 메시지 출력

> ( 관리 설정 ) : MAX client 제한

> ( 보안 설정 ) : Greeting Message 출력

> ( 보안 설정 ) : chroot 구성

> ( 보안 설정 ) : 익명사용자의 홈디렉토리

> ( 보안 설정 ) : FTP 포트 변경

> ( 보안 설정 ) : 한개 아이피에 대한 접속 제한

> ( 보안 설정 ) : 접속 사용자 제한

 

 

○ 배너 메시지 출력.

# vi /etc/vsftpd/vsftpd.conf

1
2
3
4
# 제일 하단에 
# Sfecific Configuration
#
banner_file=/etc/vsftpd/banner.txt
cs

 

# vi /etc/vsftpd/banner.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+====================================================+
|                                                   |
|        Welcome to linux252.example.com            |
|                                                   |
|                                                   |
| This is the linux252.example.com test server.     |   
|                                                   |
| If you have not already done so, make sure        |
| you have read the Downloading/Installation,       |
| FAQ, and Disclaimer links on                      |
| http://www.solaris254.example.com.                |
|                                                   |
| This is a restricted access system. All           |
| tranfers are logged.  If you disagree             |
| with this practice, log off now.                  |
|                                                   |
| Questions go to SeoungChan Baik at                |
| the address given on linux252.example.com         |
|                                                   |
|                                                   |
+====================================================+
cs

 

# service vsftpd restart

 

# ftp localhost

 

 

○ Greetin Message 출력

 

# vi /etc/vsftpd/vsftpd.conf       > 키워드는 ftpd_banner

1
2
# You may fully customise the login banner string:
ftpd_banner=Welcome to blah FTP service.            # 주석제거
cs

 

# service vsftpd restart

 

# ftp localhost

 

 

○ 사용자 FTP chroot 구성

 

# su - user01

$ cp /etc/passwd file1

$ cp file1 file2

$ cp file1 file3

$ cp file1 file4

$ exit

 

# ftp localhost    ( user01 )

> 기본적으로 인증된 사용자라면 권한이 되는 범위 안에서 다른 디렉토리로 이동이 가능하다. 이동이 가능하면 디렉토리 안의

   내용을 살펴볼 수 있기 때문에 보안상 좋지 않다.

 

ⓐ 주 설정 파일 변경

 

# vi /etc/vsftpd/vsftpd.conf

1
2
3
4
# 가장 하단에 추가.
# Sfecific Configuration
#
chroot_local_user=YES
cs

 

# ftp localhost

> 이 설정은 root에게도 적용이 된다. 보안상 아주 권장한다.

 

 

○ FTP 서버에 접근 사용자 제한

userlist_deny=YES        > 두개의 파일 중 한 개의 파일에라도 사용자가 정의되어 있으면 FTP로그인을 할 수 없다.

- /etc/vsftpd/ftpusers

- /etc/vsftpd/user_list

userlist_deny=NO        > user_list 파일에 존재하는 사용자만 FTP 로그인을 할 수 있다.

- /etc/vsftpd/ftpusers

- /etc/vsftpd/user_list

 

# vi /etc/vsftpd/vsftpd.conf

1
2
3
4
# 가장 하단에 추가
# Sfecific Configuration
#
userlist_deny=NO
cs

 

# vi /etc/vsftpd/user_list

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
user01        # 추가
cs

 

# ftp localhost    ( user01 )

 

 

# ftp localhost    ( root )

> root라고 해도 불가하다.

 

 

○ 익명사용자(Anonymous) FTP 구성

기본적으로 vsftp 프로그램이 설치되어 있으면 기본적으로 익명 사용자 FTP가 구성되어 있다.

하지만 다운로드는 가능하지만 업로드는 불가하다.

업로드를 할 수 있도록 하기 위해선 vsftp.conf 파일에서 설정을 해주면 된다.

anon_upload_enable=YES

 

보안상 권장하지 않는 설정이다.

 

ⓐ 익명사용자 FTP 디렉토리 확인

 

# cd /var/ftp    ;    ls -l

> pub가 일반 사용자들이 쓸 수 있는 폴더

 

ⓑ 익명사용자 FTP 기본 설정 테스트

 

# mkdir /var/ftp/pub/test

# cp /etc/passwd /var/ftp/pub/test

# ftp localhost

 

# firefox ftp://192.168.35.143

 

 

 

○ FTP 포트 변경

vsftp 서버에서 사용하는 FTP 서버용 포트는 기본적으로 21번이다.

"listen port" 키워드를 사용하여 FTP 서버용 포트를 다른 포트로 지정 할 수 있다.

이 경우는 기본적인 포트번호를 다른 것으로 변경해서 사용해야 하는 환경에서 유용하다.

 

# vi /etc/vsftpd/vsftpd.conf

1
2
3
4
5
6
7
# 가장 하단에 추가
# Sfecific Configuration
#
#banner_file=/etc/vsftpd/banner.txt
#chroot_local_user=YES
#userlist_deny=NO
listen_port=2121
cs

 

# service vsftpd restart

 

# ftp localhost 21

 

# ftp localhost 2121

 

○ vsftp 서버에 접속 할 수 있는 사용자수 제한

# vi /etc/vsftpd/vsftpd.conf

max_clients=3             < 추가.

> 루트도 해당된다.

 

○ 한개의 아이피에 대한 전송 제한

# vi /etc/vsftpd/vsftpd.conf

max_per_ip=3             < 추가.

> 루트도 해당된다.

 

○ 익명사용자 FTP 서버에 파일 업로드 기능 설정

# cd /var/ftp/pub

# mkdir incoming

# chmod 603 incoming

> 3 : 올릴 순 있지만 볼 수는 없다.

 

# useradd -d /var/ftp/pub/incoming -r -s /sbin/nologin ftpupload

 

# vi /etc/vsftpd/vsftpd.conf

1
2
3
4
5
6
anon_upload_enable=YES            # 주석제거
.
.
.
chown_uploads=YES                # 주석제거
chown_username=ftpupload        # 주석제거 후 사용자 이름 
cs

 

# service vsftp restart

 

 

○ 파일 다운로드 전용 FTP 서버 구성

(파일 경로/이름을 알고 있는 경우에만 다운로드 가능)

GUI 방식의 툴을 통해서는 anonymous FTP 서버의 파일을 다운로드 받을 수는 없도록 하고 싶다.

반드시 ftp CMD 를 통해서만 접속하도록 하고싶다.

mget 명령어가 아닌 get명령어를 통해서, 다운로드 받으려고 하는 파일의 이름이 정확한 경우에만 다운로드 가능하도록 하고 싶다.

 

# cd /var/ftp/pub

# mkdir -m 751 download

# cd download

# mkdir -m 751 os

# cd os

# mkdir -m 751 centos

# cd centos

# cp /etc/passwd centos5.jmg

 

# ftp localhost    ( anonymous)

ftp> cd pub

ftp> dir

ftp> cd download

ftp> dir

 

ftp> cd os

ftp> pwd

ftp> dir

ftp> cd centos

ftp> pwd

ftp> dir

 

ftp> lcd /tmp

ftp> mget centos5.jmg

ftp>

>> 다운로드가 안된다.

 

ftp> get centos5.jmg

ftp> ! ls -l /tmp | grep centos

 

반응형