1. vsftpd 설치

-

[ec2-user@ip-172-31-20-116 ~]$ sudo yum install vsftpd

Loaded plugins: priorities, update-motd, upgrade-helper

amzn-main                                                                           | 2.1 kB  00:00:00     

amzn-updates                                                                        | 2.5 kB  00:00:00     

Resolving Dependencies

--> Running transaction check

---> Package vsftpd.x86_64 0:2.2.2-13.13.amzn1 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


===========================================================================================================

 Package              Arch                 Version                           Repository               Size

===========================================================================================================

Installing:

 vsftpd               x86_64               2.2.2-13.13.amzn1                 amzn-main               161 k


Transaction Summary

===========================================================================================================

Install  1 Package


Total download size: 161 k

Installed size: 320 k

Is this ok [y/d/N]: y

Downloading packages:

vsftpd-2.2.2-13.13.amzn1.x86_64.rpm                                                 | 161 kB  00:00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : vsftpd-2.2.2-13.13.amzn1.x86_64                                                         1/1 

  Verifying  : vsftpd-2.2.2-13.13.amzn1.x86_64                                                         1/1 


Installed:

  vsftpd.x86_64 0:2.2.2-13.13.amzn1                                                                        


Complete!

[


2. VSFTP 환경설정


[ec2-user@ip-172-31-20-116 www]$ sudo vi /etc/vsftpd/vsftpd.conf 


# The name of log file when xferlog_enable=YES and xferlog_std_format=YES

# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log

#xferlog_file=/var/log/xferlog

#

# Switches between logging into vsftpd_log_file and xferlog_file files.

# NO writes to vsftpd_log_file, YES to xferlog_file

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 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().

chroot_local_user=YES   <-- home디렉토리를 FTP 접속루트로 잡고 계정도 리눅스꺼 공유해서 쓰겠다

#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=YES

#

# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6

# sockets, 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   <-- user_list 파일 사용

tcp_wrappers=YES

pasv_enable=YES          <-- passive mode 사용

pasv_min_port=1024

pasv_max_port=1048

pasv_address=11.111.222.233   <-- Public IP (외부에서 치고 들어오는 IP)


3. 리눅스 사용자 계정 추가 및 홈 디렉토리 변경하여 FTP 접속 루트 디렉토리로 지정


[ec2-user@ip-172-31-20-116 donzbox]$ sudo adduser donzbox2

[ec2-user@ip-172-31-20-116 donzbox]$ sudo passwd donzbox2

choickey 사용자의 비밀 번호 변경 중

  암호:

  암호 재입력:

passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.


[ec2-user@ip-172-31-20-116 donzbox]$ sudo usermod -d /ftp_root donzbox2  <-- donzbox2님의 홈디렉토리 /home/donzbox2 를

                                                                                       /ftp_root 로 바꾸고 FTP 접속시 절루 가게함


[ec2-user@ip-172-31-20-116 donzbox]$ sudo chmod -R 755 /ftp_root  <-- 쓰기권한 부여하지 않으면 FTP 접속은 되지만 파일업로드가 안됨

[ec2-user@ip-172-31-20-116 donzbox]$



4. VSFTPD 서버 재기동하여 위의 사항 적용

[ec2-user@ip-172-31-20-116 donzbox]$ 

[ec2-user@ip-172-31-20-116 donzbox]$ sudo service vsftpd restart

Shutting down vsftpd:                                      [  OK  ]

Starting vsftpd for vsftpd:                                [  OK  ]
[ec2-user@ip-172-31-20-116 donzbox]$


5. 접속 테스트

조낸잘댐


6. 참고

이 목록에 없는 사용자만 FTP에 접근할 수 있게 하는 설정 (파일이름이 헷갈리네 @_@)


[ec2-user@ip-172-31-20-116 www]$

[ec2-user@ip-172-31-20-116 vsftpd]$ sudo vi /etc/vsftpd/user_list


# 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.

root

bin

daemon

adm

lp

sync

shutdown

halt

mail

news

uucp

operator

games

nobody

~          


서버 재기동시 자동으로 vsftpd 가 시작되지 않게

sudo chkconfig --level 345 vsftpd on

vsftpd 제거 (환경설정 및 서비스도 날라감)

sudo yum remove vsftpd




+ Recent posts