2020. 4. 16.

[Linux] vsftp 사용 및 설정

vsftp 설치 구동확인


vsftp 설치 확인
# yum list vsftpd
Vsftpd 설치
# yum install –y vsftpd

vsftpd 서버 실행

# systemctl start vsftpd
관련 파일
데몬 : /usr/sbin/vsftpd
설정 파일 : /etc/vsftpd/vsftpd.conf
• PAM 모듈 : /etc/pam.d/vsftpd
접근 제한 파일
/etc/vsftpd/ftpusers - 플러그인 모듈 공통적인 라이브러리 제공함
/etc/vsftpd/user_list - 그래서 이거만 사용하는게 맞음


두개 있는 이유는 vsftp 리눅스에서만 쓸려고 한게 아니라 유닉스에서 쓸려고 만든거라 자체적으로 계정을 컨트롤할게 필요하다. 예전에는 윈도우 용도 있었음

yum으로 설치했기 때문에 systemctl로도 바로 실행가능

vsftpd.conf 파일 설

허용과 제한이기에 매우 중요함

Active mode 설정
pasv_enable=NO(default : YES)
클라이언트에서 passive 모드로 접속을 요청해도 active 모드로 접속

Passive mode 설정
pasv_enable=YES (default : YES)
pasv_min_port=0 (default : 0, any port)
pasv_max_port=0 (default : 0, any port)
방화벽이나 공유기 사용시에 passive mode에서 사용하는 port 번호를 등록해줘야 하기 때문에 범위를 반드시 지정

익명 사용자 관련 설정

anonymous_enable=YES
#anon_upload_enable=YES (d:NO)
#anon_mkdir_write_enable=YES (d:NO)
#deny_email_enable=YES (d:NO banned_email_file )
- banned 파일에 지정된 메일 계정은 접속이 불허된다.
#banned_email_file=/etc/vsftpd.banned_emails
#non_anon_password=NO
#anon_root=/var/ftp (d:/var/ftp)
#ftp_username=ftp (d:ftp)

제한 설정

#max_clients=30
#max_per_ip=3 (0은 무제한)
#ls_recurse_enable=YES (ls –R 명령은 부하가 크다)

chroot 설정(루트 디렉토리를 바꾼다)
자기 홈디렉토리 안에서만 작업 있다.

#chroot_local_user=YES (d:No)
#chroot_list_enable=YES
- chroot_local_user NO일 때 chroot_list_file에 지정된 사용자만 chroot를 적용
- chroot_local_user YES일 때 chroot_list_file에 지정된 사용자만 chroot를 적용하지 않는다.
#chroot_list_file=/etc/vsftpd/chroot_list
- Default : /etc/vsftpd/chroot_list
#allow_writeable_chroot=YES
- chroot 적용 사용자의 경우 이 설정이 반드시 필요

• chroot 설정은 외부 디렉토리로 연결된 link 디렉토리에 접근도 금지, 이때는 mount 명령을 이용
mount --bind [원본 디렉토리] [연결할 디렉토리]

standalone 인 경우만 사용되는 항목

listen=YES
tcp_wrappers=YES
- /etc/hosts.deny, /etc/hosts.allow 파일에 정의
- vsftpd : 192.168.10.
마지막에 .은 패턴을 지정 - 192.168.10.x 대역 포함
local_max_rate=1024 # byte/sec
anon_max_rate=1024


등록된 사용자(/etc/passwd) 관련 설정

local_enable=YES
write_enable=YES
local_umask=022


사용자 제한 설정(user_list)

• userlist_file(/etc/vsftpd/user_list)에 등록된 계정에 대한 접속제어는 userlist_enable userlist_deny에 따라 결정
• userlist_enable defaul No지만 YUM으로 설치된 경우 Yes 설정

Yes 
Yes 
No 
Yes 
No 
01 
user_list 
user_list 
userlist_enable01 Noe 
userlist_dentj 
userlist_filee


사용자 제한 설정(ftpusers)
PAM(Pluggable Authentication Module)에 의한 접속 제어는 앞서 userlist를 이용한 방법과 유사하다. 이 기능은 /etc/pam.d/vsftpd 파일에 접속 제한 방식을 설정하고 접속이 제한된 계정의 목록은ftpusers 파일을 이용

pam_service_name = vsftpd
- vsftpd 서버의 PAM 제어를 위한 서비스명을 등록한다. 등록된 이름으로
/etc/pam.d/에 설정 파일이 만들어진다.

/etc/pam.d/vsftpd 파일 설정에 따라 제한 설정이 달라진다.
/etc/vaftpd/ftpusers가 목록 파일로 정의되어 있다. 만일 sense 설정
deny가 아니라 allow 변경하면 ftpuser 파일에 등록된 사용자만
FTP 서버 접속이 허용
둘중에 하나만 써야한다.

/etc/pam.d/vsftpd
: sense [deny | allow] 설정에 따라 /etc/vsftpd/ftpusers 설정이 바뀐다.
• Deny : ftpusers에 등록된 계정은 ftp 접속을 불허
• Allow : ftpusers에 등록된 계정만 ftp 접속을 허용

auth required pam_listfile.so item=user sense=deny
file=/etc/vsftpd/ftpusers onerr=succee


yum list vsftpd
yum install –y vsftpd

base: 
.navercorp.com 
* epel: ftp.iij.ad.jp 
extras: mirror.navercorp.com 
rpmforge: mirror.chpc.utah.edu 
updates: ftp.nara.wide.ad.jp 
Available Packages 
vsftpd.x86_64 
Croot@cent152 yum list vsftpd 
Loaded plugins: fastestmirror, langpacks 
Loading mirror speeds from cached hostfile 
9.ø 
2.9 
1.9 
3.ø.2-25.e17 
Croot@cent152 yum install -y vsftpd 
Loaded plugins: fastestmirror, langpacks 
Loading mirror speeds from cached hostfile 
epeI/x86_64/metaIink 
* base: kddilabs.jp 
epel: hk.mirrors.thegigabit.com 
* extras: kddilabs.jp 
rpmforge: mirror. teklinks . com 
updates: ftp-st•.'2.kddilabs.jp 
base 
e pel 
extra s 
r pmforge 
base 
ka 
4 
.7

ntsysv
vsftp 켜준다.


systemctl stop vsftpd
systemclt start vsftpd
systemctl start vsftpd
systemctl status vsftpd

ftp를 켜준다.


groupadd -g 9000 test
useradd -g 9000 -u 9000 test
passwd test

테스트 계정을 만든다.


su test
cd
whoami
pwd
touch hello
ls
exit
테스트를 계정으로 파일을 만든다.



ftp 192.168.10.152
test
pwd
ls
만든 파일이 있는지 확인한다.


cat /etc/vsftpd/vsftpd.conf

Croot@cent152 systemctl start vsftpd 
Croot@cent152 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 conunent this out). 
# Llnccmment this to allow local users to log in. 
# When SELinux is enforcing check for SE bool 
local enable=YES 
# Llncc«nent this to enable any form of FTP write connand. 
write enable=YES 
# Default umask for local users is ø77. You may wish to change this to ø22, 
# if your users expect that (ø22 is used by most other ftpd's) 
local umask=ß22 
# Llnccmment 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 allow ft 
full access 
# Llnccmment this if you want the anonymous FTP user to be able to create 
# new directories. 
#anon mkdir write enable=YES 
# Activate directoy messages - 
# go into a certain directoy. 
dimes 
messages given to remote users when they 
# Activate logging of uploads/downloads. 
xferlog_en a ble=YES 
# Make sure PORT transfer connections originate from port 2ø (ftp-data). 
2ø=YES

cat /etc/pam.d/vsftpd

Croot@cent152 cat /etc/pam.d/vsftpd 
*VAN-I. e 
session 
auth 
ers 
auth 
auth 
account 
session 
session 
optional 
req u i red 
req u i red 
include 
include 
req u i red 
include 
pam_keyinit. so 
force revoke 
pam_listfile.so item—user sense—deny file=/etc/vsftpd/ftpus 
pam_shells . so 
password-auth 
password-auth 
pam_loginuid . so 
password-auth 
Croot@cent152

cat /etc/vsftpd/ftpusers

Croot@cent152 cat /etc/vsftpd/ftpusers 
# Users that are not allowed to login lia ftp 
daemon 
sync 
shutdown 
halt 
mail 
news 
uucp 
operator 
games 
nobody 
Croot@cent152

cat /etc/vsftpd/user_list

Croot@cent152 cat /etc/vsftpd/user_list 
# vsftpd user-list 
# If only allow users in this file 
# If (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. 
daemon 
sync 
shutdown 
halt 
mail 
news 
uucp 
operator 
games 
nobody 
Croot@cent152

댓글 없음:

댓글 쓰기