728x90
- 프로그램 설치
sudo apt-get install vsftpd
- 프로그램 설정
sudo vim /etc/vsftpd.conf
- 포트변경
listen=NO 밑에
listen_port=21(포트번호) - 권한설정
write_enable=YES 주석해제
local_umask=022 주석해제 - 메시지 설정
ftpd_banner=Welcome to wook FTP service. - 계정 홈디렉토리 상위폴더 이동제한
chroot_local_user=YES 주석해제 - ftp 접속 허용 계정 설정
chroot_list_enable=NO 주석해제 및 변경
chroot_list_file=/etc/vsftpd.chroot_list 주석해제 - pasv 모드 설정(선택)
pasv_enable=YES
pasv_min_port=2101
pasv_max_port=2200
allow_writeable_chroot=YES
- 포트변경
- ftp 접속 가능 계정 추가
계정명 추가 (1행당 1계정명)
vim /etc/vsftpd.chroot_list # 비어있는 파일에 접속 허용할 계정 추가 # ex) ftp_user # abc_user # 이런식으로 한 줄에 한 계정씩
- 프로그램 재시작
sudo service vsftpd restart
vsftp2 추가 방법(더 추가할시 방법 동일)
- conf파일 복사 및 수정
cp /etc/vsftpd.conf /etc/vsftpd2.conf vim /etc/vsftpd2.conf
listen=YES listen_port=21111(원하는 포트) listen_ipv6=NO ... xferlog_file=/var/log/vsftpd2.log # 주석 해제 및 수정 ... secure_chroot_dir=/var/run/vsftpd2/empty pam_service_name=vsftpd2
- sbin 파일 복사
cp /usr/sbin/vsftpd /usr/sbin/vsftpd2
- service 파일 복사 및 수정
cp /usr/lib/systemd/system/vsftpd.service usr/lib/systemd/system/vsftpd2.service vim /usr/lib/systemd/system/vsftpd2.service
:%s/vsftpd/vsftpd2 :%s/server/server2 # 또는 아래 내용으로 수정 [Unit] Description=vsftpd2 FTP server2 After=network.target [Service] Type=simple ExecStart=/usr/sbin/vsftpd2 /etc/vsftpd2.conf ExecReload=/bin/kill -HUP $MAINPID ExecStartPre=-/bin/mkdir -p /var/run/vsftpd2/empty [Install] WantedBy=multi-user.target
- init.d폴더의 vsftpd파일 복사 및 수정
cp /etc/init.d/vsftpd /etc/init.d/vsftpd2
:%s/vsftpd/vsftpd2 :%s/vsftpd.pid/vsftpd2.pid # 또는 아래 내용으로 수정 #!/bin/sh ### BEGIN INIT INFO # Provides: vsftpd2 # Required-Start: $network $remote_fs $syslog # Required-Stop: $network $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Very secure FTP server2 # Description: Provides a lightweight, efficient FTP server written # for security. ### END INIT INFO set -e DAEMON="/usr/sbin/vsftpd2" NAME="vsftpd2" PATH="/sbin:/bin:/usr/sbin:/usr/bin" LOGFILE="/var/log/vsftpd2.log" CHROOT="/var/run/vsftpd2/empty" test -x "${DAEMON}" || exit 0 . /lib/lsb/init-functions if [ ! -e "${LOGFILE}" ] then touch "${LOGFILE}" chmod 640 "${LOGFILE}" chown root:adm "${LOGFILE}" fi if [ ! -d "${CHROOT}" ] then mkdir -p "${CHROOT}" fi case "${1}" in start) log_daemon_msg "Starting FTP server" "${NAME}" if [ -e /etc/vsftpd2.conf ] && ! egrep -iq "^ *listen(_ipv6)? *= *yes" /etc/vsftpd2.conf then log_warning_msg "vsftpd2 disabled - listen disabled in config." exit 0 fi start-stop-daemon --start --background -m --oknodo --pidfile /var/run/vsftpd2/vsftpd2.pid --exec ${DAEMON} n=0 while [ ${n} -le 5 ] do _PID="$(if [ -e /var/run/vsftpd2/vsftpd2.pid ]; then cat /var/run/vsftpd2/vsftpd2.pid; fi)" if ps -C vsftpd2 | grep -qs "${_PID}" then break fi sleep 1 n=$(( $n + 1 )) done if ! ps -C vsftpd2 | grep -qs "${_PID}" then log_warning_msg "vsftpd2 failed - probably invalid config." exit 1 fi log_end_msg 0 ;; stop) log_daemon_msg "Stopping FTP server" "${NAME}" start-stop-daemon --stop --pidfile /var/run/vsftpd2/vsftpd2.pid --oknodo --retry 30 --exec ${DAEMON} RET=$? if [ $RET = 0 ]; then rm -f /var/run/vsftpd2/vsftpd2.pid; fi log_end_msg $? ;; restart) ${0} stop ${0} start ;; reload|force-reload) log_daemon_msg "Reloading FTP server configuration" start-stop-daemon --stop --pidfile /var/run/vsftpd2/vsftpd2.pid --signal 1 --exec $DAEMON log_end_msg "${?}" ;; status) status_of_proc "${DAEMON}" "FTP server" ;; *) echo "Usage: ${0} {start|stop|restart|reload|status}" exit 1 ;; esac
- 추가한 vsftpd 시작
sudo systemctl enable vsftpd2 sudo systemctl start vsftpd2
'개발 지식 > 리눅스' 카테고리의 다른 글
[Ubuntu] Apache2 SSL인증 설정(https) (0) | 2024.03.20 |
---|---|
[Ubuntu] 간단한 SSH 설정방법 (0) | 2024.01.17 |
[Ubuntu] 계정 추가,제거, 디렉토리 설정 등등 (0) | 2024.01.17 |
[Jetson] Serial 번호 확인 방법 (0) | 2024.01.16 |
[Ubuntu] VNC 화면공유 설정 (0) | 2024.01.14 |