'os/UNIX_LINUX'에 해당되는 글 238건

  1. 2016.03.30 vsftpd 패키지 설치

반응형


vsftpd 패키지 설치 여부 확인

[root@localhost ~]# rpm -qa vsftpd
[root@localhost ~]#

 

vsftpd 패키지 설치 작업 진행

[root@localhost ~]# yum -y install vsftpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
 * base: ftp.kaist.ac.kr
 * extras: ftp.kaist.ac.kr
 * updates: ftp.kaist.ac.kr
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:2.2.2-14.el6_7.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================
 Package             Arch    Version            Repository   Size
==================================================================
Installing:
 vsftpd              x86_64  2.2.2-14.el6_7.1   updates     152 k

Transaction Summary
==================================================================
Install       1 Package(s)

Total download size: 152 k
Installed size: 332 k
Downloading Packages:
vsftpd-2.2.2-14.el6_7.1.x86_64.rpm            | 152 kB     00:00
경고: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
 Package: centos-release-6-5.el6.centos.11.1.x86_64 (@base/$releasever)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : vsftpd-2.2.2-14.el6_7.1.x86_64                       1/1
  Verifying  : vsftpd-2.2.2-14.el6_7.1.x86_64                       1/1

Installed:
  vsftpd.x86_64 0:2.2.2-14.el6_7.1

Complete!
[root@localhost ~]#

 

패키지 설치 여부 확인

[root@localhost ~]#  rpm -qa vsftpd
vsftpd-2.2.2-14.el6_7.1.x86_64
[root@localhost ~]#


패키지 설치 위치 확인

[root@localhost ~]# rpm -ql vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-2.2.2
/usr/share/doc/vsftpd-2.2.2/AUDIT
/usr/share/doc/vsftpd-2.2.2/BENCHMARKS
/usr/share/doc/vsftpd-2.2.2/BUGS
/usr/share/doc/vsftpd-2.2.2/COPYING
/usr/share/doc/vsftpd-2.2.2/Changelog
/usr/share/doc/vsftpd-2.2.2/EXAMPLE
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/logins.txt
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2/README
/usr/share/doc/vsftpd-2.2.2/FAQ
/usr/share/doc/vsftpd-2.2.2/INSTALL
/usr/share/doc/vsftpd-2.2.2/LICENSE
/usr/share/doc/vsftpd-2.2.2/README
/usr/share/doc/vsftpd-2.2.2/README.security
/usr/share/doc/vsftpd-2.2.2/REWARD
/usr/share/doc/vsftpd-2.2.2/SECURITY
/usr/share/doc/vsftpd-2.2.2/SECURITY/DESIGN
/usr/share/doc/vsftpd-2.2.2/SECURITY/IMPLEMENTATION
/usr/share/doc/vsftpd-2.2.2/SECURITY/OVERVIEW
/usr/share/doc/vsftpd-2.2.2/SECURITY/TRUST
/usr/share/doc/vsftpd-2.2.2/SIZE
/usr/share/doc/vsftpd-2.2.2/SPEED
/usr/share/doc/vsftpd-2.2.2/TODO
/usr/share/doc/vsftpd-2.2.2/TUNING
/usr/share/doc/vsftpd-2.2.2/vsftpd.xinetd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz
/var/ftp
/var/ftp/pub
[root@localhost ~]#

 

패키지 설치 여부 확인

[root@localhost ~]# rpm -qa ftp
[root@localhost ~]#

패키지 설치 작업 진행

[root@localhost ~]# yum -y install ftp
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.kaist.ac.kr
 * extras: ftp.kaist.ac.kr
 * updates: ftp.kaist.ac.kr
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ftp.x86_64 0:0.17-54.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================
 Package             Arch   Version     Repository  Size
=========================================================
Installing:
 ftp                 x86_64 0.17-54.el6 base        58 k

Transaction Summary
=========================================================
Install       1 Package(s)

Total download size: 58 k
Installed size: 95 k
Downloading Packages:
ftp-0.17-54.el6.x86_64.rpm                           |  58 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : ftp-0.17-54.el6.x86_64                   1/1
  Verifying  : ftp-0.17-54.el6.x86_64                   1/1

Installed:
  ftp.x86_64 0:0.17-54.el6

Complete!
[root@localhost ~]#

패키지 설치 여부 확인

[root@localhost ~]#  rpm -qa ftp
ftp-0.17-54.el6.x86_64

[root@localhost ~]#

패키지 설치 위치 확인

[root@localhost ~]# rpm -ql ftp
/usr/bin/ftp
/usr/bin/pftp
/usr/share/man/man1/ftp.1.gz
/usr/share/man/man1/pftp.1.gz
/usr/share/man/man5/netrc.5.gz
[root@localhost ~]#

 

vsftpd 관련된 환경 파일 목록

/etc/vsftpd/vsftpd.conf            # 환경 설정 파일
/etc/vsftpd/ftpusers               # 접근 제한 리스트
/etc/vsftpd/user_list              # 접근 허용 리스트
/etc/vsftpd/chroot_list            # 접속 후 상위 디렉토리까지 이동할 유저 리스트
/etc/vsftpd/vsftpd_conf_migrate.sh


vsftpd.conf 환경 파일 설정 변경

[root@localhost ~]# vi /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.
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.
#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
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
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
#
# 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
#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
tcp_wrappers=YES
------------------------------------------------------------------------

vsftpd.conf 환경 파일 설명

listen=YES                 (독립데몬으로 서비스하려면 yes)
listen_ipv6=YES            (IPV6 사용여부)
anonoymous_enable=YES      (익명사용자 접속 허용yes/제한no)
local_enable=YES           (local 계정 접속 허용yes/제한no)
write_enable=YES           (쓰기허용yes/제한no)
local_umask=022            (새로생성되는 파일(666-022=644)/디렉토리의 퍼미션설정(777-022=755))
dirmessage_enable=YES      (디렉토리 이동시 메시지 노출 여부 yes/no)
use_localtime=YES          (서비스 로컬 시간 사용 여부 )
xferlog_enable=YES         (로그 기록 허용여부)
xferlog_std_format=YES     (std format 허용)
xferlog_file=/var/log/vsftpd.log (로그 저장 위치)
connect_from_prot_20=YES   (20번 포트에 데이터 전송연결을 허용 할건지yes/말건지no)
idle_session_timeout=600   (ftp접속후 600초동안 아무것도 안하면 강제 로그아웃)
data_connection_timeout=120(데이터전송에 120초의 시간제한)
ftpd_banner=Welcome to ~   (ftp서버로 접속할 때 출력되는 메시지)
tcp_wrappers=YES           (tcp_wrappers의 접근제어를 받도록 설정한다yes)
chroot_local_user=YES      (자기자신의 홈디렉토리 상위디렉토리로 이동하는것을 제한yes/허용no)
chroot_list_enable=YES     (chroot_list 파일 사용 여부 - 해당 파일에 있는 유저만 허용)
chroot_list_file=/etc/vsftpd.chroot_list
allow_writeable_chroot=YES
userlist_enable=YES        (/etc/vsftpd/user_list 파일을 활성화한다yes)
user_config_dir=/etc/vsftpd_user_conf
pam_serivce_name=vsftpd    (pam설정 파일명을 지정, 경로 /etc/pam.d/vsftpd)
ssl_enable=YES             (SSL 사용여부 - ssl_enable상태일 경우 ssl아니면 비허용 )
rsa_cert_file=/etc/vsftpd.pem
rsa_private_key_file=/etc/vsftpd.pem
force_local_logins_ssl=YES
force_local_data_ssl=NO
require_ssl_reuse=NO
ssl_ciphers=HIGH
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
allow_anon_ssl=NO
pasv_enable=YES          (PASSIVE 모드 여부)
pasv_promiscuous=YES
pasv_min_port=20001
pasv_max_port=20010
listen_port=20000
ftp_data_port=20001

 

ftpusers 환경 파일 설정


[root@localhost ~]# vi /etc/vsftpd/ftpusers

# Users that are not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody


user_list 환경 파일 설정

[root@localhost ~]# 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


설명 : root계정에 대해서 ftp를 허용하고자 할 경우 ftpusers 와 user_list 파일에서 root 계정앞에 # 으로 주석 처리를 수행한다.

 

부팅시 자동 실행 설정

[root@localhost ~]# chkconfig vsftpd on

[root@localhost ~]# chkconfig | grep vsftpd
vsftpd          0:해제  1:해제  2:활성  3:활성  4:활성  5:활성  6:해제


부팅시 자동 실행 중지 설정

[root@localhost ~]# chkconfig vsftpd off

[root@localhost ~]# chkconfig | grep vsftpd
vsftpd          0:해제  1:해제  2:해제  3:해제  4:해제  5:해제  6:해제


vsfpt 실행

[root@localhost /]# /etc/init.d/vsftpd start
vsftpd에 대한 vsftpd을 시작 중: [  OK  ]

[root@localhost /]#
[root@localhost /]# ps -ef | grep vsftpd | grep -v grep
root      7064     1  0 00:24 ?        00:00:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
[root@localhost /]#

 


오류 발생시 -  500 oops cannot change directory /root

[root@localhost ~]# ftp localhost
Connected to localhost (127.0.0.1).
220 (vsFTPd 2.2.2)
Name (localhost:root): root
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/root
Login failed.
ftp>


[root@localhost ~]# setsebool -P ftp_home_dir=1


[root@localhost ~]# ftp localhost
Connected to localhost (127.0.0.1).
220 (vsFTPd 2.2.2)
Name (localhost:root): root
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/root
Login failed.
ftp>
ftp> quit
221 Goodbye.
[root@localhost ~]#

[root@localhost ~]# setsebool -P allow_ftpd_full_access=1
[root@localhost ~]# ftp localhost
Connected to localhost (127.0.0.1).
220 (vsFTPd 2.2.2)
Name (localhost:root): root
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
ftp> quit
221 Goodbye.
[root@localhost ~]#

[root@localhost ~]# ftp localhost
Connected to localhost (127.0.0.1).
220 (vsFTPd 2.2.2)
Name (localhost:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quit
221 Goodbye.
[root@localhost ~]#

 

 

반응형
Posted by 공간사랑
,