sftp 는 설정이 사실 별거 없었는데 vsftpd 하면서 에로사항이 좀 있었어가지고 까먹지 않고자 메모해둔다.
sftp 는 너무나도 잘되는데 ..
ftp 접속이 죽어도 안되는 현상이 발생. (connection refused)
vsftpd 가 안될때 뭐 여러 가지 케이스가 있는데
1. vsftpd 가 가동중이지 않거나 (systemctl status vsftpd)
2. 포트가 (Listen) 중이지 않거나 (netstat -tnlp | grep ftp)
3. 방화벽 문제거나 (firewall-cmd --list-all)
#사용할 ftp 포트, 사용중인 zone 안에 잘 추가되었는지 확인
firewall-cmd --zone=public --permanent --add-port=49021/tcp
대부분 위 중에 하나긴한데 나는 저 위에 어떠한것도 아니었고
애초에 hosts.deny 에 ALL : ALL 로 되있어서 모두 차단되고있던 상태였고,
vi /etc/hosts.allow 파일에 내 아이피 추가해줘서 해결했다
ftp 설정파일 내용 정리
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=NO
#
# 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
file_open_mode=0644
#
# 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=NO
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
# 명시된 사용자만 로그인을 허용할 때 (기본값 NO)
# userlist_deny 옵션이 비활성화 된 상태에서만 작동
userlist_enable=NO
## 명시된 사용자가 로그인을 할 수 없도록 제한하는 옵션 (기본값 YES)
### => userlist_enable 옵션이 NO 일때만 작동
userlist_deny=YES
#
# 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. 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=NO
pam_service_name=vsftpd
listen_port=39021
pasv_enable=YES
pasv_min_port=39020
pasv_max_port=39020
allow_writeable_chroot=YES
#local_max_rate=32768000
#virtual_use_local_privs=YES
vi /etc/vsftpd/chroot_list
root
vi /etc/vsftpd/ftpusers
#root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
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 접속시 핵심은 물론 포트도 중요하지만 그 외 부가적으로
chroot_local_user=YES
chroot_list_enable=NO
#chroot_list_file=/etc/vsftpd/chroot_list
userlist_enable=NO
userlist_deny=YES
pasv_enable=YES
pasv_min_port=39020
pasv_max_port=39020
위 세팅들도 아주 중요하다, 제대로 안맞춰주면 , 접속은 성공적으로 되었다하더라도, 디렉토리 조회가 안될수도 있고 , 별의별 permission denied 가 환영해준다
그리고 pasv port 를 조정했다면 방화벽에서도 꼭 .. 꼭 조정해야한다.
이부분 잊지말자
#로컬 윈도우 방화벽 FTP 에 한하여 허가 등록
netsh advfirewall firewall add rule name="FTP" dir=in action=allow program=%SystemRoot%\System32\ftp.exe enable=yes protocol=tcp
netsh advfirewall firewall add rule name="FTP" dir=in action=allow program=%SystemRoot%\System32\ftp.exe enable=yes protocol=udp
#해제
netsh advfirewall firewall delete rule name="FTP" program=%SystemRoot%\System32\ftp.exe
'IT > 잡다구리' 카테고리의 다른 글
[Github] Github Actions 사용하는법 , SSH 연결 (6) | 2021.12.09 |
---|---|
[Window] 명령 프롬프트 에서 Linux 접속 500 Illegal PORT command, 425 Use PORT or PASV first (0) | 2021.12.09 |
[Jenkins] 리눅스에 젠킨스 설치 (0) | 2021.12.01 |
[Linux] 도커 방화벽 관련 메모, 방화벽이 무시되는 docker 컨테이너 --iptables=false (0) | 2021.11.18 |
[Git] branch 덮어씌우기 (0) | 2021.11.17 |