카테고리 없음

Raspberry PI, FPT 서버 만들자 (VSFTPD)

LEEHANDS 2022. 2. 22. 15:40
반응형

VSFTPD 설정

경로는 /etc/vsftpd

파일은 ftpusers , usere_list , vsftpd.conf

 

명령어

sudo service vsftpd restrat  -- 재시작
sudo service vsftpd status   -- 상태확인

vsftpd.conf 설정

단어 사전

: anonymous  : 익명 

: inetd ( internet sevice daemon ) : 유닉스 시스템에서 돌아가는 슈퍼 서버 데몬으로 인터넷 서비스 들을 제공한다.

       -- 슈퍼 데몬이라고도 함 

       -- 시스템의 효율성을 높이기 위해 사용자의 서비스 요청이 있을 때 해당 데몬 프로세스를 생성하여 사용자의 요청에 대응하는 방식

: daemon : 주기적인 서비스 요청을 처리하기 위해 계속 실행되는 프로그램

  

 

listen

  - vsftp 데몬은 기본적으로 inetd 모드로 동작

  - 독립모드 (Standalone) 으로 데몬을 운용하려면 listen = YES 으로 설정

  - Inetd 모드로 운용할려면 NO 으로 설정하고 많은 접속이 없는 경우 Ineted 가 유리함 

  --- Recommand :  listen = NO , listen_ipv6 =YES ( listen 은 둘중 하나는 YES 해야함 )

 

anonymous_enable=NO      # 익명허용 여부


local_enable  #  로컬 사용자 계정 사용 여부

  - ftp 서버 운영에 등록된 로컬 등록자에게 접속을 허용한다.

  -- Recommand : local_enable = YES


write_enable=NO  # 쓰기권한허용 여부
local_umask=022  # 파일 및 디렉토리 생성시 권한 부여값

   - 로컬계정 사용자들의 umask 값을 설정 ( Default = 022 )(vsftpd 는 077)

 
anon_upload_enable=YES  # 익명 업로드 허용여부
anon_mkdir_write_enable=YES # 익명 디렉토리 생성 허용 여부
dirmessage_enable=YES # 접속시 메시지 표시 여부
connect_from_port_20=YES # 20번포트를 FTP에 사용 여부
chown_uploads = YES  # 관리자계정으로 업로드한 파일의 소유주를 변경 허용 여부
chown_username=whoever # 위 설정과 같이 사용 뭔지 모르겠다
xferlog_file=/var/log/xferlog # 업로드 및 다운로드 log 기록 경로
xferlog_std_format = YES.  # log파일 표준 포멧 사용 여부
idle_session_timeout = 600  # 시간 제한 옵션
data_connection_timeout=120 # 데이터 전송 시간 제한 옵션
nopriv_user=ftpsecure  # 관리자 계정 접속시 해당 계정으로 접속
async_abor_enable = YES # ABOR 명령어 사용가능 여부 < 필요없을 듯>
ascii_upload_enable =YES # ASCII 파일 업로드 가능 여부
ftpd_banner = Welcome~ # 접속자에게 보여질 문구
banned_email_file = /etc/vsftpd/bannerd_emails #위 옵션과 연동 파일

 

chroot_local_user = YES # 사용자가 접속시 상위폴더 접근 거부 여부

chroot_list_enable=YES # 사용자가 접속시 상위폴더로 이동 가능 여부

   - 명시된 사용자가 자신의 홈상위 디렉토리에 접근할 수 없도록 설정

   - 이옵션은 chroot_local_user 옵션이 비활성화되어있어야 사용할 수 있음
chroot_list_file=/etc/vsftpd/chroot_list # 위설정에서 제외될 사용자 계정 리스트

 

 

ls_rescurse_enable=YES  # ls -r 명령어 사용 가능 여부 (큰 FTP서버일 경우 서버 부하 있음)
listen=NO # standalone mode 로 서비스할 경우 설정하는 옵션

   = 독립모드로 데몬을 운영할려면 이 옵션을 모두 YES 으로 설정해야한다.

listen_ipv6=YES # 위와 동일
pam_service_name = vsftpd # 사용자 계정에 대한 접속을 허용할 때 PAM 인증 사용시 사용파일 이름 지정
userlist_enable = YES

     user_list , ftpusers

     userlist_enable 이 YES 일 경우 두파일에 명시된 계정들은 접근이 안되며 간단하게 설명해서

     NO 인 경우 ftpusers 에만 명시된 계정들이 접근안된다.

     기본적으로 root 는 모두 차단되어있는데 가능하게 하려면 이 두파일에 있는 root를 지우거나 주석처리해야한다.

 

home directory

local_root=/home/pi/ftp

 

※ DOCKER & GITLAB & FTP 서버용 참고 configuration files

# Example config file /etc/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.
#
#
# Run standalone?  vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
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.
listen_ipv6=YES
#
# Allow anonymous FTP? (Disabled by default).
anonymous_enable=YES
anon_root=/home/pi/ftp-server
#
# Uncomment this to allow local users to log in.
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
#local_root=/home/pi
#
# 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.
#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
#
# If enabled, vsftpd will display directory listings with the time
# in  your  local  time  zone.  The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=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/vsftpd.log
#
# 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.
# 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 Leehands 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 restrict local users to their home directories.  See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# 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
allow_writeable_chroot=YES

#userlist_enable=YES
#userlist_file=/etc/vsftpd.user_list
#userlist_deny=NO
#
# 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
#
# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO

#
# Uncomment this to indicate that vsftpd use a utf8 filesystem.
#utf8_filesystem=YES
반응형