별의 공부 블로그 🧑🏻‍💻
728x90
728x170

vsftpd

vsftpd

  • Very Secure FTP Daemon
  • 리눅스에서 사용하는 대표적인 FTP 서버 프로그램
  • 간결하고 안전하며 처리 속도도 매우 빠른 프로그램
  • 리눅스 및 유닉스 계열에서 사용할 수 있다.
  • RHEL, Fedora, CentOS, Ubuntu, Slackware 등의 배포판에 기본적으로 포함되어 있다.
  • 환경 설정 시 YES/NO로 설정하도록 되어 있다.
  • 보안 관련 점검을 많이 한다.
    • 특히 anonymous 계정에 대한 검사를 많이 한다.
      • anonymous 관련 디렉터리의 퍼미션이 777로 설정되어 있으면 로그인을 막는다.

 

(참고) FTP(File Transfer Protocol)

더보기
  • TCP/IP 프로토콜 기반으로 서버와 클라이언트 사이에 파일을 주고 받기 위한 프로토콜
  • FTP 를 사용하기 위해서는
    • FTP 서버를 구축해야 한다.
    • 서버에 접속하기 위한 계정(아이디 및 패스워드)이 필요하다.
      • 일반적인 FTP 서버는 서버에 등록된 계정만 이용 가능하다.
      • 공개 소프트웨어를 공유하는 서버에서 익명의 계정(anonymous)을 이용해서 파일을 다운로드 할 수 있다.

 

vsftpd 서버 설정

(1) vsftpd 관련 주요 파일

  • /etc/vsftpd/vsftpd.conf : vsftpd의 환경 설정 파일
  • /etc/pam.d/vsftpd : vsftpd의 PAM 관련 설정 파일
  • /etc/vsftpd/ftpusers
    • PAM 관련 설정 파일인 /etc/pam.d/vsftpd에 사용되는 파일
    • 기본 설정이 접근 거부될 사용자 목록으로 이용됨.
  • /etc/vsftpd/user_list
    • vsftpd를 이용하는 사용자 목록 파일
    • 허가 또는 거부 목록 파일로 사용할 수 있음.
    • 기본 설정이 userlist_deny=YES여서 거부 목록 파일로 사용됨.
  • /etc/logrotate.d/vsftpd : vsftpd의 로그 로테이트 관련 파일

 

(2) vsftpd.conf 파일 분석

# cat /etc/vsftpd/vsftpd.conf
더보기
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

 

항목 1

anonymous_enable=YES
  • 익명 계정의 허가 유무 지정
  • 기본 설정 : 사용 가능

 

항목 2

local_enable=YES
  • 로컬 사용자, 즉 일반 계정 사용자의 허가 유무 지정
  • 기본 설정 : 사용 가능
  • 주석 처리 NO로 지정하면 익명 사용자만 가능함.

 

항목 3

write_enable=YES
  • 쓰기가 가능할 것인지를 지정하는 항목
  • 주석 처리하게 되면 파일이나 디렉터리 생성이 불가능함.

 

항목 4

local_umask=022
  • 디렉터리나 파일 생성 시 퍼미션 값을 지정함.

 

항목 5

anon_upload_enable=YES
  • 익명의 사용자들도 업로드가능하도록 지정함.
  • 기본 설정 : 주석 처리 (익명의 사용자는 다운로드만 가능)

 

항목 6

anon_mkdir_write_enable=YES
  • 익명의 사용자들이 디렉터리를 만들 수 있도록 하는 설정
  • 기본 설정 : 주석 처리 (디렉터리 생성 불가능)

 

항목 7

dirmessage_enable=YES
  • 접속 시, 메시지를 보여줄 것인지 여부 지정
  • 보통 사용자의 홈 디렉터리에 .message라는 파일에 메시지를 적어 놓으면 접속 시에 나타남.
  • anonymous는 레드햇 계열 리눅스에서 /var/ftp라는 디렉터리로 연결되므로 이 디렉터리 안에 설정하면 됨.

 

항목 8

xferlog_enable=YES
  • 파일 업로드 및 다운로드 관련 로그를 기록할 것인지 지정
  • 관련 로그는 /var/log/vsftpd.log 파일에 기록됨.

 

항목 9

connect_from_port_20=YES
  • ftp의 데이터 포트 20번의 사용 유무 지정

 

항목 10

chown_uploads=YES
  • anonymous 계정으로 업로드한 파일의 소유권을 변경하도록 할 때 사용
  • 이 설정은 chown_username 항목과 같이 사용해야 함.

 

항목 11

chown_username=whoever
  • chown_uploads=YES와 같이 사용됨.
  • 외부에서 anonymous 계정으로 업로드된 파일의 소유권이 이 항목에 지정한 사용자로 변경됨.

 

항목 12

xferlog_file=/var/log/xferlog
  • 로그 파일명을 지정하는 옵션
  • 기본적으로 주석 처리 되어 있음.
  • 해당 파일을 사용할 경우에는 로그 로테이트 관련 파일도 수정해야 함.

 

항목 13

xferlog_std_format=YES
  • 로그 기록할 때 표준 포맷 사용 여부 지정
  • NO : vsftpd에서 사용하는 로그 포맷으로 전환

 

항목 14

idle_session_timeout=600
  • 기본 타임아웃 시간을 지정하는 항목
  • 단위 : 초

 

항목 15

data_connection_timeout=120
  • 데이터 전송 관련 타임아웃 시간을 지정하는 항목
  • 단위 : 초

 

항목 16

ftpd_banner=Welcome to blah FTP service.
  • 서버 접속 시에 나타나는 메시지를 지정할 때 사용
  • 기본적으로 주석 처리 되어 있음.
    • vsftpd 서버의 버전이 메시지로 나타남.

 

항목 17

chroot_local_user=YES
  • 접속한 사용자의 홈 디렉터리를 최상위 디렉터리로 지정
  • 이 지시자를 사용하면 모든 접속자에게 적용됨.

 

항목 18

chroot_list_enable=YES
  • 지정한 사용자의 홈 디렉터리를 최상위 디렉터리로 지정할 때 사용하는 항목
  • 다음 지시자인 chroot_list_file과 같이 쓰임.

 

항목 19

chroot_list_file=/etc/vsftpd/chroot_list
  • chroot_list_enable=YES 지시자와 같이 사용됨.
  • 이 파일에 적용할 사용자를 한 줄에 한 명씩 적으면 됨.

 

항목 20

ls_recurse_enable=YES
  • FTP 서버 접속 상태에서 ls -R 명령 사용 시, 하위 디렉터리까지 검색 가능 여부 지정

 

항목 21

listen=YSE
  • IPv4 기반으로 standalone 모드로 사용할 경우에 지정하는 항목

 

항목 22

listen_ipv6=YES
  • IPv6 기반으로 사용할 경우에 지정하는 항목

 

항목 23

pam_service_name=vsftpd
  • PAM 서비스의 이름 지정

 

항목 24

userlist_enable=YES
  • 사용자가 직접 목록 파일을 작성하여 지정한 사용자들의 접근을 막을 수 있도록 하는 설정
  • 추가적으로 userlist_file=파일명 을 지정해야 함.

 

항목 25

tcp_wrappers=YES
  • TCP Wrappers 를 이용하여 접근 제어할 것인지를 지정하는 항목
  • /etc/hosts.allow  /etc/hosts.deny 파일을 이용함.

 

항목 26

session_support=YES
  • vsftpd 서버에 접속한 내역을 /var/log/wtmp 파일에 기록하여 last 명령으로 확인할 때 설정하는 항목

 

항목 27

max_clients=50
  • 최대 접속자를 지정하는 항목

 

항목 28

max_per_ip=3
  • 한 IP 주소 당 허용할 접속수를 지정하는 항목

 

728x90
그리드형(광고전용)
⚠️AdBlock이 감지되었습니다. 원할한 페이지 표시를 위해 AdBlock을 꺼주세요.⚠️
starrykss
starrykss
별의 공부 블로그 🧑🏻‍💻


📖 Contents 📖